🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

madex

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

madex

render dynamic template, fast and easy

unpublished
latest
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Madex

** This module is under development, but you can try it now because it's ready to use already. **

###Render dynamic data to your template easily. this module is superfast and lightweight, works using simple Js functions.

##Example

html [index.html]


	<body>
		<%name%> // single % for output
		<%% if (user){echo(user.name)}%> // double %% for controlling
		<%names[1]%>
		<%cat.color%>
		<%include("somefile.txt")%>
	</body>

now node.js

	
	var madex = require("madex");
	
	var data = fs.readFileSync("./index.html");
	
	var obj={
		name:"John",
		user:{name:"Smith"},
		name:["John", "Doe", "Smith"],
		cat : {color:"white", name:"mew"}
	}
	madex.render(data, obj, function(output){
		console.log(output);
	});
	

render() takes three params, first one the data read from file, second one an object containing to be rendered datas and third one a callback function with one param, the returning output.

echo() is a function introduced to print outputs, which takes one argument.

files get automatically included ( the last line in html page).

##change the delimeter if you dont like it


	madex.delim = "$" //or anything else
	

Sync version of render() is renderSync()

var output = madex.renderSync(data, obj);

two parameters. first one the data read from file and second one the list to be renderd datas.

Keywords

template

FAQs

Package last updated on 30 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts