D 2013-10-18T18:34:52.689
L home
N text/x-markdown
P 46a7ebeebed1a0d151f00cb26490b509495c295f
U carlosru
W 3998
PreprecessorJS
PreprecessorJS is a simple parser to transform simple tokens into <script></script> tags, and
rewrites the generated markup,or better said is a kind of preprocessor like PHP, JSP, ASP but using the native
Javascript as language.
Download :
PreprocessorJS Zip File
Download :
PreprocessorJS tar.gz File
Example:
The default pair of tokens used for
preprocessorJS (PJS) are
"{?" and "?}" and for assignament
{?=([JavascriptVar]) ?} inside these tokens should go javascript code.
You can change the pair of tokens inside the preprocessorJS.js changing openToken,assignamentToken and closeToken variables.
So for example:
{? var name="Alice";
var where="in the wonderland";
?}
<h2>The book is {?=(name);?} {?=(where);?} </h2>
And the tokens are mixed and embeded in a html page, that will be preprocessed loading
the preprocessorJS.js javascript on the load event in the body tag and calling changeIt() function.
<head>
<script src="./lib/preprocessorJS.js" type="text/javascript"></script>
</head>
<body onload="changeIt();">
The resulted markup will be something like:
<h2>The book is Alice in the wonderland</h2>
You can also have very simple if-block like this
{? if(name="Alice"){ ?};
<p>Some markup..</p>
{? } else { ?};
<p>Other markup...</p>
?}
Finally in this version, you can have just GET parameters comming from a HTML Form.
Using the array parms['parName'] where 'parName' is the parameter corresponding to the
name of the elements in your form.
var name=
{?
var name=params['theName'];
?}
This is licenced under Apache 2.0
And the repository is a Fossil one on
SCM processJS
Please, donate
or contribute to improve it or use it without
any warranty, just
in the spirit to have a handy tool that could help!.
This script was developed by carlosru@factware.info , please use Fossil site.
To rise bugs, and ask for a user to contribute to the project.
Z 68d59980552dc1c2da631cba38eba65d