DownloadConverting JML Code to HTML
This case study demonstrates how Ascoos OS takes a clean, small, safe .jml file and automatically converts it into complete and valid HTML5.
Purpose
-
Automatic conversion of JML to HTML5
-
Reduction of code compared to manual HTML
JML Documentation
Main Classes of Ascoos OS
-
THTML : JML parser + HTML generator
-
TFilesHandler : Secure writing of the generated HTML to a file
File Structure
The implementation is contained in a single PHP file:
- jml_to_html_renderer.php
It includes all the logic: interpreting JML, converting to HTML, and saving to an HTML file.
Prerequisites
-
PHP ? 8.2
-
Installed Ascoos OS or
AWES 26
Execution Flow
-
Configure operational properties.
-
Initialize the classes.
-
Declare the `JML` string.
-
Parse the JML string into HTML.
-
Manually add the DOCTYPE.
-
Save the generated HTML to a file.
-
Display the generated HTML code.
-
Release resources and handlers.
Code Example
html:lang('en') {
head {
title {`Untitled-1`}
meta:charset('utf-8')
meta:name('description'),content('')
link:rel('icon'),type('image/x-icon'),href('./favicon.ico')
}
body {
h1{`Hello JML World`}
}
}
Expected Result
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Untitled-1</title>
<meta name="description" content="">
<link rel="icon" type="image/x-icon" href="./favicon.ico">
</head>
<body>
<h1>Hello JML World</h1>
</body>
</html>
Resources
License
This study is covered by the Ascoos General License (AGL). See LICENSE.md. |