![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A lightning fast template parser for node.js
thunder is one of the fastest template parsers for node.js
. Checkout the benchmarks for its performance. The usage is quite simple, evaluation
, interpolation
, and interpolation with html escaping
. All variables and functions must start with it
for performance sake. thunder works well with Express
, check out the examples folder for the setup.
via npm:
$ npm install thunder
Evaluate javascript expression
<? ?>
<? if( it.user ){ ?>
<p>User exist</p>
<? } ?>
Simple output ( no escape )
<?= ?>
// script = '<script>alert( 'this is harmful' );</script>';
<?= it.script ?>
// prints out <script>alert( 'this is harmful' );</script>
Simple output ( escape ) | & < > "
--> & < > "
<?- ?>
// script = '<script>alert( 'this is gonna be fine' );</script>';
<?- it.script ?>
// prints out <script>alert( 'this is gonna be fine' );<script/>
Require the module before using
var thunder = require( 'thunder' );
returns the text ready to be compiled for the compile
function
input
type: String
desc: Input string to be compiled
options:
type: Object
props:
compress:
type: Boolean
default: false
desc: Whether to compress the output HTML
var input = '<div>Hello, this is <?= it.name ?> :)</div>';
var compiled_text = thunder.compiled_text( input );
console.log( compiled_text );
// var __t__='<div>Hello, this is ';__t__+= it.name ;__t__+=' :)</div>';return __t__;
returns the compiled function
input
type: String
desc: Input string to be compiled
options
type: Object
props:
compress:
type: Boolean
default: false
desc: Whether to compress the output HTML
var input = '<div>Hello, this is <?= it.name ?> :)</div>';
var render = thunder.compile( input );
// it actually turns to the following function
// function ( locals ){
// var __t__='<div>Hello, this is ';__t__+= locals.name ;__t__+=' :)</div>';return __t__;
// };
returns the cached compiled function
input
type: String
desc: Input string to be compiled
options
type: Object
props:
compress:
type: Boolean
default: false
desc: Whether to compress the output HTML
var input = '<div>Hello, this is <?= it.name ?> :)</div>';
var render = thunder.cached( input );
// it actually turns to the following function and will be cached
// so that next time the text does not need to be compiled again
// function ( locals ){
// var __t__='<div>Hello, this is ';__t__+= locals.name ;__t__+=' :)</div>';return __t__;
// };
returns the output
input
type: String
desc: Input string to be compiled
locals
type: Object
desc: Variables to be passed to the compiled function
options
type: Object
props:
compress:
type: Boolean
default: false
desc: Whether to compress the output HTML
cached:
type: Boolean
default: false
desc: Whether to cache the compiled function
var input = '<div>Hello, this is <?= it.name ?> :)</div>',
var locals = { name : 'Bibi' };
var options = {
cached : true,
compress : true
};
var output = thunder.render( input, locals, options );
console.log( output );
// <div>Hello, this is Bibi :)</div>
app.configure( function(){
...
app.set( 'view engine', 'html' );
app.register( '.html', require( 'thunder' ));
// optional
app.set( 'view options', {
compress : true
});
...
});
To use express
partial
,helper
anddynamic helper
just call the method but start withit
.
// partial
<?= it.partial( 'common/_nav' ) ?>
// helper
<a class="<?= it.selected( 'somewhere', it.nav_selected )?>" href="/somewhere">Somewhere</a>
Checkout the
examples
folder for more details.
$ cd /path/to/thunder/examples/simple
$ node run.js
$ cd /path/to/thunder/examples/complex
$ node run.js
$ cd /path/to/thunder/examples/express
$ npm install -lf
$ node app.js
The followings are some well-known template parsers that I took for Benchmarks. You are welcome to fork it and add more. There are 2 main parts, the compiling speed and the rendering speed. The compiled templates are cached in jqtpl
, Swig
and thunder. Therefore their benchmarks for compiling is much faster. You can change the compile method from cached
to compile
to see the none-cached speed for thunder.
To run the benchmarks just type the following commands in the terminal
$ git clone git://github.com/dreamerslab/thunder.git
$ cd thunder/benchmarks/
$ npm install -lf
$ node run.js
(The MIT License)
Copyright (c) 2011 dreamerslab <ben@dreamerslab.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0.0.2 / 2012-02-15
FAQs
One of the fastest JavaScript template engine for Node.js and browsers.
The npm package thunder receives a total of 23 weekly downloads. As such, thunder popularity was classified as not popular.
We found that thunder 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.