1.1.4 • Published 5 years ago

@rexfng/tpl v1.1.4

Weekly downloads
2
License
ISC
Repository
-
Last release
5 years ago

Tpl

Description

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

Options

OptionsTypeDescriptionExample
domStringThe option dom takes in a string of already rendered html string<html></html>
headArray of StringsStrings 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>"]
bottomArray of StringsStrings 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)	
1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago