
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
A fast and easy-to-use template language for every langauge (XML, HTML, SQL, CSS)
One of the fastest and easy-to-use template language for every langauge (XML, HTML, SQL, CSS)
Rein is german/dutch for clean, neat and that was exactly the goal of this project, create a clean and neat template language.
It's another template langauge! It originally was a template langauge for SQL. but after I ported it to JavaScript, it became suitable for HTML too! and after some tweaking it became one of the fastest template engines there is
When you need a simple, lightweight and superfast template engine, that can be used server side but also client side
for NodeJS you first need to install it with the following command and then you can go wild!
npm i rein
and for the web you need add Rein(.min).js to your page, (note that compiling a template takes more time then just executing it, f.x. a different template langauge may be faster in compiling the template but is most likely not faster in executing it, so its recommend to compile the templates serverside)
Server.js
var fs = require('fs');
var rein = require('rein');
var templates = {
list:rein(fs.readFileSync('./list.rein')),
friends:rein(fs.readFileSync('./friends.rein'))
};
// createBundle will make a little javascript script
// with the compiled templates ready to execute client side
// via the ReinBundle function, so if you send jsCode
// to your client and execute it there
// you can fully use that as described in Client.js
var jsCode = rein.createBundle(templates);
Client.js
// ReinBundle takes 2 arguments, id and args
// the id is from the object which is used to generate
// this bundle.
var html = ReinBundle('list',{ items:["soap","shampoo","wig"] });
// The client side version is very simple
// with Rein you build your template
// and with Template.parse you (compile and) execute it
var tpl = Rein("Your are customer <strong>{{nr}}</strong>");
var html = tpl.parse({nr:425});
The template syntax is simple, easy to use and fluid. at least, I tried to make it that way.
variables just work as you expect them to work, you can also execute functions and all the things you would normally do between a (
and )
I'm {{name}} and I'm {{age}} old, I'm a {{gender.name}}, and {{this()}} is my weapon!
if's are structured like {{ expression : MOAR TEMPLATE }}
, well that's simple isn't it?!
There is currently no else :( I will work on that!
{{gotKids && doIReallyGotKids():
I got like {{numKids}} kids! You can have {{ numKids - ((numKids + hisNumKids)/2) }} kids from me if you want?
}}
for loops are almost like if's {[ variable : TEMPLATE INCEPTION ]}
, it won't get much harder!
Although there are some things you need to know!
first off we reset the scope of the for to the current object we are looping on, so be aware of that! we also add the following variables to the for scope, I mean, these could be usefull, sometimes, like when you need it.
__i
: current index
__amount
: length of current array
__first
: returns true if this is the first element
__last
: returns true if this is the last element
{[arr:
Im {{__first: the first }} looping: {{this}}
{{__last: bye bye!}}
]}
Well. that's it! now create your own neat adventures! and be sure to give some (supportive) feedback.
Rein(tpl)
alias for Rein.build(tpl)
Rein(tpl,vars)
alias for Rein.build(tpl).parse(vars)
.createBundle(tplobj)
returns code for the client with a bundle of template code.build(tpl)
build template and return Rein.Template object.Template
template object
.parse(vars)
parses template and returns a string with the parsed template.compile()
compiles template to 1 function, which works like .parse(vars)
Rein.js is licensed under the MIT License (see LICENSE)
FAQs
A fast and easy-to-use template language for every langauge (XML, HTML, SQL, CSS)
The npm package rein receives a total of 0 weekly downloads. As such, rein popularity was classified as not popular.
We found that rein 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
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.