QuickView is a lightweight JavaScript-based templating engine designed to dynamically render HTML pages. It offers a simple syntax to embed variables and execute conditional statements and loops within HTML files.
- Variable Interpolation: Use
{{ variableName }}
for dynamic content. - Conditional Blocks: Execute conditionals using
@if
,@elseif
,@else
, and@endif
. - Looping: Loop through arrays with
@foreach
and@endforeach
. - File Inclusion: Include external HTML files using
@include('fileName')
. - Data Fetching: Fetch and embed JSON data from URLs or objects.
Include the quickview.js
file in your HTML project:
<script src="path/to/quickview.js"></script>
Variable Replacement
<h1>{{ siteName }}</h1>
@if(someCondition)
<!-- HTML content -->
@elseif(anotherCondition)
<!-- HTML content -->
@else
<!-- HTML content -->
@endif
@foreach(items)
<p>{{ itemName }}</p>
@endforeach
@include('header')
Initialize the QuickView engine with a data source object containing either local variables or external URLs:
qv({
"localVariable": "value",
"externalData": "http://example.com/data.json",
});
<h1>{{ siteName }}</h1>
@foreach(users)
<p>Name: {{ name }}, Age: {{ age }}</p>
@endforeach
qv({
"siteName": "My Site",
"users": [
{"name": "Alice", "age": 25},
{"name": "Bob", "age": 30}
]
});
qv({
"siteName": "My Site",
"users": "http://example.com/users.json"
});
[
{"name": "Alice", "age": 25},
{"name": "Bob", "age": 30}
]
Contributions are welcome! Feel free to open an issue or submit a pull request to improve the engine.