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

Using Smarty in PHP and Javascript both

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
umakantp
Smarty n00b


Joined: 19 Feb 2015
Posts: 1

PostPosted: Thu Feb 19, 2015 6:50 am    Post subject: Using Smarty in PHP and Javascript both Reply with quote

You have been using Smarty in PHP and want to use it Javascript as well.

Here is the answer:- jSmart https://github.com/umakantp/jsmart

Usually you render all your template via PHP but say you want a modal dialog or anything to be shown via Javascript. You are normally left with two options.

1. Get the parse template from PHP via Ajax or so and show that
2. Write hard codded HTML in Javascript.

Using jSmart now you have 3rd option. You can now share templates with PHP and Javascript and both can make use of same templates.
Read template and parse in Javascript using jSmart. It normally supports all the syntax of Smarty 3.

Functions which are PHP specific like if you are using isset, empty...etc. These functions can be defined in Javascript as well and put to work. If you go to git repositories documentation you can see various examples of how to use it.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat Jul 11, 2015 9:49 pm    Post subject: Reply with quote

I like this project. Smile
Back to top
View user's profile Send private message Visit poster's website
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 -> Tips and Tricks 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