node-jshp

2.0.0 • Public • Published

node-jshp

node-jshp is template engine that support asynchronous mode for Node.

-------Update Info ----------

<LI>
	2.0.0 <BR>
	There are two big change in jshp. <BR>
	First,you will not call async_mode() fater version 2.0, because jshp always run in asynchronous mode now.<BR>
	Next,sync_print() and async_print() will replaced by echo(),or you prefer print(),you can use it too. 
</LI>
<LI>
	1.1.1 <BR>
	Release domain when after process script.
</LI>

<LI>
	1.1.0 <BR>
	1. Append new function exit() replace end(). The exit() function can ensure stop and exit script <BR>
	2. The callback of constructed function add new field "err" now, like this
		<CODE>fn(params,function(err,cb_data){ console.log(cb_data); });</CODE>
</LI>
Install - npm ========= npm install node-jshp

Usage - How to Use

index.jshp

<?

run_async(function(){ //execute asynchronous task
	some_async("a",function(data){
	?>
	<? echo(data);?> 
	
	<?
		next();//do next task
	});
});
?>

parse_test.js

var fs = require("fs");
var jshp_parser = require("node-jshp");

fs.readFile("index.jshp", function(err, data) {
		
	if(err) throw err;
	
	jshp_parser.parse(data.toString(),"/var/www/",function(err,fn){
		
		if(err)	throw err;
		var params={a:1};
		fn(params,function(err,cb_data){
			console.log(cb_data);
		});
	});
)

Usage - The functions

run_async:join a asynchronous task
example:

	
		run_async(function(){
		});

echo:like echo in php
example:

		echo("hello");

next:do next asynchronous task
example:

		run_async(function(){
			next();
		});
		run_async(function(){
		});

exit:exit this script
example::

			exit() or exit("leave");		

License

(The MIT License)

Copyright (c) 2014 Chun-Yen Wu

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.

Package Sidebar

Install

npm i node-jshp

Weekly Downloads

15

Version

2.0.0

License

none

Last publish

Collaborators

  • enoch