https://github.com/rohitnairtech/inhtml
Lightweight html generator to create sever-side-rendering pages with ease
https://github.com/rohitnairtech/inhtml
Last synced: about 2 months ago
JSON representation
Lightweight html generator to create sever-side-rendering pages with ease
- Host: GitHub
- URL: https://github.com/rohitnairtech/inhtml
- Owner: rohitnairtech
- Created: 2020-09-18T10:02:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-20T09:26:32.000Z (3 months ago)
- Last Synced: 2025-03-20T10:30:26.473Z (3 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# inHTML



inHTML is a lightweight HTML templating engine written in NodeJS. It allows you to pre-render HTML templates with ease using simple placeholders and partials.
## Features
- Lightweight and fast HTML rendering
- Supports placeholders using `#{variableName}`
- Supports partial templates using `#{>partialName}`
- Optional HTML escaping to prevent XSS## Installation
Use the package manager [npm](https://www.npmjs.com/) to install inHTML.
```bash
npm install inhtml
```## Usage
### Basic Example
```html
Hi, #{name}
``````javascript
const inHTML = require('inhtml');
const welcomePage = inHTML('./welcome.html');const finalHTML = welcomePage.render({
link: 'https://github.com/rohitnairtech',
name: 'Rohit Nair'
});console.log(finalHTML);
// Output: 'Hi, Rohit Nair
'
```---
### Using Partials
You can reuse HTML templates using partials with `#{>partialName}`.
```html
Welcome, #{name}!
``````html
#{>header}
Your profile is ready.
``````javascript
const inHTML = require('inhtml');
const layoutPage = inHTML('./layout.html', {
partials: {
header: 'Welcome, #{name}!
'
}
});const finalHTML = layoutPage.render({ name: 'Rohit' });
console.log(finalHTML);
// Output: ''Welcome, Rohit!
Your profile is ready.
```---
### HTML Escaping
To prevent XSS attacks, you can enable HTML escaping.
```javascript
const inHTML = require('inhtml');
const page = inHTML('./welcome.html', { escapeHtml: true });const finalHTML = page.render({
name: 'alert("XSS")',
link: 'https://example.com'
});console.log(finalHTML);
// Output: 'Hi, <script>alert("XSS")</script>
'
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## License
[ISC](https://www.isc.org/)