Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Javascript templates with Smarty

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
sileence
Smarty n00b


Joined: 14 Nov 2010
Posts: 4

PostPosted: Wed Jun 01, 2011 12:00 am    Post subject: Javascript templates with Smarty Reply with quote

Hi! I started using smarty 3 some months ago and it's very cool. Before that, I used a self-made template engine.

I'm writting here because I miss a feature that I had in my own engine.

The feature was the possibilty of compiling templates like HTML/JAVASCRIPT instead of HTML/PHP. For example, something like

Code:
<script type="text/js_tpl" id="my_template">
hola {$nombre}
</script>

Compiled to:

Code:
<script type="text/js_tpl" id="my_template">
r += 'hola'; r += T.nombre;
</script>

And I had a jquery template which allowed me to do something like:

Code:
$('#id_field').render('#id_template')


etc.

I'd like to do the same with Smarty, and I think I can, but I need to use the smarty parse to convert variables or functions into $matches arrays that I can finally convert to HTML/JS by my own.

Finally, the question is how can I use the smarty parse to analyze smarty vars or functions? And where do you think is the right place to do that? In the prefilters or in a compiler function?

Thank you in advance.

Regards.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP