[ANN] jsTemplate 0.2

W

wezzy

Released version 0.2 of jsTemplate!

What is this
--------------
It's a very small library (just 4k minified) written in javascript that
allows you to write template file similar to PHP or ASP but using
JavaScript.
The main advantage of this solution is the fact that the client's
browser perform all the operations and it frees your server. Your web
server has only to send a static file and it has more resources to do
really important task like data access.
We developed this as an evolution from the code of StickyShare and we
plan to use it for future releases.

What's new?
--------------
* better IE support
* internal refactoring
* bug fix

Where ?
----------
jsTemplate is hostend on Sourceforge

http://jstemplate.sourceforge.net/
http://sourceforge.net/projects/jstemplate/

License ?
 
A

ASM

wezzy a écrit :
Released version 0.2 of jsTemplate!

What is this

Where to find examples (and detailed use) ?
(something more than a loop to write same line or so)
 
F

Fabio Trezzi

ASM said:
Where to find examples (and detailed use) ?
(something more than a loop to write same line or so)

At this time the only example online is the simple for example, but the
usage is very simple.

You have two kind of tag the <# code#> contains javascript code and <#=
something #> prints out variable value. The only addition at the plain
Javascript is a write function. It's more a macro than a function
because it's expanded to _jtfOutput.push(value)
As you may expect writing

<#= val #>

is the same of writing:

<# write(val) #>

You can write everything you want inside the <# #> tags.
These tags are chosen because are different from the standard <? ?> tags
of PHP or the <% %> of ASP and so you can mix PHP code with JST.
The only restriction is not using _jtfOutput for a variable name into
your code.

a template like this:

<#
for(var i = 0; i < limit; i ++){
#>
<br />Alert <#= i #>
<#
}
#>

<br /> The end

become a code like this:

function template(limit){
var _jtfOutput = [];
for(var i = 0; i < limit; i ++){
_jtfOutput.push("<br />Alert");
_jtfOutput.push(i);
}
_jtfOutput.push("<br /> The end);
return _jtfOutput.join('');
};

I'm writing a new test page that prints the translated template before
the result, but now you can already test your ideas here:

http://jstemplate.sourceforge.net/test.php

For any question or idea just post :)
Thanks for you time!

Fabio "Wezzy" Trezzi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top