Artifact [2fa8d0d48b]

Artifact 2fa8d0d48be8df0af663179a021a0edf2d26809e:

Wiki page [home] by carlosru 2013-10-16 21:19:04.
D 2013-10-16T21:19:04.719
L home
P e5aae41d9efe4553e7e3db3298b2d9ad791595b8
U carlosru
W 5946
<div>&lt;html&gt;</div>

<div>&lt;head&gt;</div>

<div>&lt;meta http-equiv="cache-control" content="no-cache"&gt;</div>

<div>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;</div>

<div>&lt;style type="text/css"&gt;</div>

<div>&nbsp; &nbsp; body { font-family:arial, verdana}</div>

<div>&nbsp; .codigo{ color:#C00000;}

<span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;</div>

<div>&lt;/style&gt;</div>

<div>&lt;/head&gt;</div>

<div>&lt;body &gt;</div>

<div>&lt;div style="margin-left:50px;margin-right=50px;"&gt;</div>

<div>&lt;br /&gt;</div>

<div>&nbsp;&lt;font color='blue'&gt;&lt;h1
align="center"&gt;PreprecessorJS&lt;/h1&gt;&lt;/font&gt;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;&lt;p&gt;</div>

<div>&nbsp;PreprecessorJS is a simple parser to transform simple tokens into
&amp;lt;script&amp;gt;&amp;lt;/script&amp;gt; tags, and</div>

<div>&nbsp;rewrites the generated markup,or better said is a kind of
preprocessor like php, jsp, asp but using the native</div>

<div>&nbsp;javascript as language.&lt;/p&gt;</div>

<div>&nbsp;</div>

<div>&nbsp;&lt;h2&gt;Example:&lt;/h2&gt;</div>

<div>&nbsp;</div>

<div>&nbsp;The default pair of tokens used for &lt;font
color="#009966"&gt;preprocessorJS&lt;/font&gt; (PJS) are &lt;b&gt;"{?" and "?}"
&lt;/b&gt; and for assignament &lt;b&gt;{?=([JavascriptVar]) ?}&lt;/b&gt;
inside these tokens should go javascript code.</div>

<div>&nbsp;You can change the pair of tokens inside the preprocessorJS.js
changing openToken,assignamentToken and closeToken variables.&lt;br /&gt;</div>

<div>&nbsp;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;So for example:&lt;br /&gt;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;&lt;div class="codigo"&gt;</div>

<div>&nbsp;{? &nbsp;var name="Alice";&lt;br /&gt;</div>

<div>&nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var where="in the
wonderland";&lt;br /&gt;</div>

<div>&nbsp;?}&lt;br /&gt;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;&amp;lt;h2&amp;gt;The book is {?=(name);?} &amp;amp;nbsp;
{?=(where);?} &amp;lt;/h2&amp;gt;&lt;br /&gt;</div>

<div>&nbsp;&lt;/div&gt;</div>

<div>&nbsp;&lt;br /&gt;&nbsp;</div>

<div>&nbsp;And the tokens are mixed and embeded in a html page, that will be
preprocessed loading&lt;br /&gt;</div>

<div>&nbsp;the preprocessorJS.js javascript on the load event in the body tag
and calling changeIt() function.&lt;br /&gt;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;&lt;div class="codigo"&gt;</div>

<div>&nbsp;&amp;lt;head&amp;gt;&lt;br /&gt;</div>

<div>&nbsp; &amp;lt;script src="./lib/preprocessorJS.js"
type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;</div>

<div>&nbsp;&amp;lt;/head&amp;gt;&lt;br /&gt;</div>

<div>&lt;br /&gt;</div>

<div>&amp;lt;body onload="changeIt();"&amp;gt;&lt;/div&gt;&lt;br /&gt;</div>

<div>&lt;br /&gt;</div>

<div>The resulted markup will be something like:&lt;br /&gt;</div>

<div>&lt;div class="codigo"&gt;&amp;lt;h2&amp;gt;The book is Alice in the
wonderland&amp;lt;/h2&amp;gt;&lt;/div&gt;&lt;br /&gt;</div>

<div>&lt;br /&gt;</div>

<div>You can also have very simple if-block like this&lt;br /&gt;</div>

<div>&lt;div class="codigo"&gt;</div>

<div>&nbsp;{? &nbsp;if(name="Alice"){ ?};&lt;br /&gt;</div>

<div>&nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p&amp;gt;Some
markup..&amp;lt;/p&amp;gt;&lt;br /&gt;</div>

<div>&nbsp;{? &nbsp;} else { ?};&lt;br /&gt;</div>

<div>&nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p&amp;gt;Other
markup...&amp;lt;/p&amp;gt;&lt;br /&gt;</div>

<div>&nbsp;?}&lt;br /&gt;</div>

<div>&lt;/div&gt;&nbsp;</div>

<div>&lt;p&gt;</div>

<div>&nbsp;Finally in this version, you can have just GET parameters comming
from a HTML Form.</div>

<div>&nbsp;Using the array &lt;b&gt;parms['parName']&lt;/b&gt; where 'parName'
is the parameter corresponding to the</div>

<div>&nbsp;name of the elements in your form.&lt;br /&gt;</div>

<div>&nbsp;var name=</div>

<div>&nbsp;</div>

<div>&nbsp;&lt;div class="codigo"&gt;</div>

<div>&nbsp;{? &nbsp;&lt;br /&gt;</div>

<div>&nbsp; &nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var
name=params['theName'];&lt;br /&gt;</div>

<div>&nbsp;?}&lt;br /&gt;</div>

<div>&nbsp;&lt;/div&gt;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;This is licenced under Apache 2.0&lt;br /&gt;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;And the repository is a Fossil one on &lt;a
href="https://chiselapp.com/user/carlosru/repository/processorjs"&gt;SCM
processJS&lt;/a&gt;&lt;br /&gt;</div>

<div>&nbsp;&lt;br /&gt;</div>

<div>&nbsp;Please, donate &lt;br /&gt;&lt;br /&gt;</div>

<div>&nbsp;&lt;form action="https://www.paypal.com/cgi-bin/webscr"
method="post" target="_top"&gt;</div>

<div>&lt;input type="hidden" name="cmd" value="_s-xclick"&gt;</div>

<div>&lt;input type="hidden" name="hosted_button_id" value="RA782FJ6V3ZE4"&gt;</div>

<div>&lt;input type="image"
src="https://www.paypalobjects.com/en_US/MX/i/btn/btn_donateCC_LG.gif"
border="0" name="submit" alt="PayPal - The safer, easier way to pay
online!"&gt;</div>

<div>&lt;img alt="" border="0"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1"
height="1"&gt;</div>

<div>&lt;/form&gt; &lt;br /&gt;&nbsp;</div>

<div>&nbsp;or contribute to improve it or use it without &lt;i&gt;any
warranty&lt;/i&gt;, just&lt;br /&gt;</div>

<div>&nbsp;in the spirit to have a handy tool that could help!.&lt;br /&gt;</div>

<div>&lt;br /&gt;&nbsp;</div>

<div>&lt;p&gt;</div>

<div>&nbsp;This script was developed by &lt;a
href="mailto:carlosru@factware.info"&gt;carlosru@factware.info &lt;/a&gt;,
please use Fossil site.</div>

<div>&nbsp;To rise bugs, and ask for a user to contribute to the project.</div>

<div>&nbsp;&lt;/p&gt;</div>

<div>&lt;/div&gt;</div>

<div>&lt;/body&gt;</div>

<div>&lt;/html&gt;</div><nowiki></nowiki>

Z da4f9323ef2d582bdaf0c1bcb6a2e1fc