Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
tplcpl
Advanced tools
Readme
This is a command-line utility to compile javascript templates (currently Jade and Underscore) for use client-side.
TplCpl compiles a whole directory of your project's templates into single JS-file and optionally minifies them with Uglify.js.
Install TplCpl from npm:
sudo -g npm install tplcpl
tplcpl --help
Global (-g
) installation is preferred to use the command line tool.
Usage:
tplcpl -t path/to/templates -o path/to/templates.js -c
You have to pass -t
and -o
options - templates directory and output JS-file respectively.
-c
option means "compress" - minify output file with Uglify.js.
During compilation a directory is traversed recursively.
Template engine to compile with is chosen by file's extension.
Jade templates must have .jade
extension, underscore templates - .us
extension.
Download and run tplcpl-setup.exe Windows installer
TplCpl is installed to C:\tplcpl.
C:\tplcpl\bin\tplcpl -t path\to\templates -o path\to\templates.js -c
Under windows please avoid spaces in paths.
After templates are compiled, they may be used as following:
var html = Templating.tpl('my/template.jade', {foo:'bar'});
console.log(html);
A Templating namespace provides also a convenient way to add tpl()
helper to your javascript "class".
Suppose we have an OOP module like this:
var MyModule = function () {
};
MyModule.prototype.myMethod = function () {
};
//etc...
Then we make:
Templating.enable(MyModule);
Now instances of MyModule will have a tpl()
method:
var inst = new MyModule;
var h = inst.tpl('my/template.jade', {foo:'bar'});
Since tpl()
is added with Templating.enable
, templates rendering functions are bound to the calling object.
So in your jade or underscore templates you can use this
variable referring to the object that calls tpl()
.
There is a missing feature in Underscore templates - an escaping.
So it is added here.
Now
<%=variable%>
is used to escape special characters in a variable.
To show variable without escaping you should use:
<%-variable%>
I have written TplCpl for private use, so it is not a universal tool.
Feel free to fork it or submit an issue if you want to add any missing features.
FAQs
Templates Compiler
The npm package tplcpl receives a total of 4 weekly downloads. As such, tplcpl popularity was classified as not popular.
We found that tplcpl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.