Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Javascript templates with Smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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