@rexfng/tpl

1.1.4 • Public • Published

Tpl

Description

Tpl provides helpers that append html node to a html file.

Options

Options Type Description Example
dom String The option dom takes in a string of already rendered html string <html></html>
head Array of Strings Strings to be inserted in the tag if it is unfound from "dom", will be appended. They will be appended in the order of the array. ["<script></script>", "<style></style>"]
bottom Array of Strings Strings to be inserted in the end of ["<script></script>", "<style></style>"]

Usage

const Template = require('@rexfng/tpl')
let tpl = Template.init({
	dom: Mustache.render("<html><head><style>h2{color:brown;}</style></head><h2 class='title'>{{title}}</h2> spends {{calc}}</html>", view),
	head: [
		'<style>h2{color:red;}</style>'
	],
	bottom: [
		'<script>alert("script appended 1!");</script>',
		'<script>alert("script appended 2!");</script>',
		'<script>alert("script appended 3!");</script>'
	]
})

//can be use in express or http
res.set('Content-Type', 'text/html');
res.send(tpl)	

Readme

Keywords

none

Package Sidebar

Install

npm i @rexfng/tpl

Weekly Downloads

1

Version

1.1.4

License

ISC

Unpacked Size

2.12 kB

Total Files

3

Last publish

Collaborators

  • rexfng