Exemplo n.º 1
0
// Parses a description to create some custom HTML: 
//- ##NAME() will be replaced with <code><a href="NAME.html">NAME()</a></code>
//- #ID#NAME() will be replaced with <code><a href="ID.html">NAME()</a></code>
//- ##ID# bla bla ## will be replaced with <a href="NAME.html"> bla bla </a>
function parseDescription(desc, paragraphSeparator, plainText) {
	return _.toString(desc)
		.replace(/##(\w+)#([^#]+)##/g, function(all, id, text) { // ##id#any text##
			return plainText ? text :  "<a href='"+id.toLowerCase()+".html'>"+text+"</a>";
		})
		.replace(/#(\w*)#([\w$.]+)\(\)/g, function(all, id, name) { // #id#name()  
			var rId = id || name;
			return plainText ? name : "<code><a href='"+rId.toLowerCase()+".html'>"+name+"()</a></code>";
		})
		.replace(/\n\n/mg, paragraphSeparator || '');
}
Exemplo n.º 2
0
exports.processFile = function(templatePath, path) {
	return runTemplate(hanson.parse(_.toString(fs.readFileSync(path))));
};
Exemplo n.º 3
0
function loadTemplate(path) {
	if (templateFuncs[path])
		return;
	
	templateFuncs[path] = _.template(_.toString(fs.readFileSync(path)), _.escapeHtml);
}