|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 05, 2012 2:38 pm Post subject: Re: What are the best delimeters then? |
|
|
Juggler wrote: | What are the best delimeters then?
What I've seen
{{ }}
{# #}
<{ }>
Obviously to hide them from html developers/designers and not interfere with javascript? |
The best delimiters are { }
Use Smarty 3 and put whitespace around them, and Smarty 3 ignores them.
Code: | <script>
function foo { // smarty ignores this
return;
} // this too
</script> |
|
|
Back to top |
|
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Fri Dec 07, 2012 3:20 pm Post subject: |
|
|
Mohrt, what about ending javascript delimiters with }; ?
Must that be ' };' or ' } ;' or ' }; ' to get ignored?
I always took the last and that seems to work, but I would like to know exactly. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Dec 07, 2012 3:24 pm Post subject: |
|
|
" } ;" would get ignored.
[edit] double check with Uwe, but }; might get ignored to, or }[anything]. you can test in a template and see what you get as well. |
|
Back to top |
|
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Fri Dec 07, 2012 4:35 pm Post subject: |
|
|
" } ;" and " };" both work fine. (...did not check for anything )
edit: - and even "};" does! |
|
Back to top |
|
solidrock Smarty n00b
Joined: 27 Apr 2016 Posts: 2
|
Posted: Wed Apr 27, 2016 5:19 am Post subject: javascript for months |
|
|
Hi, I am trying to make this work. You guys know why it is not working for me? I am using vTiger template.
function fechameses()
{
var d = new Date("{$RECORD.invoicedate}");
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var n = month[d.getMonth()];
} {literal} fechameses(){/literal}</script> |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
Posted: Wed Apr 27, 2016 7:26 am Post subject: Re: javascript for months |
|
|
All inside literal tags will be ignored by Smarty - also the Smarty var {$RECORD.invoicedate}
Try this
Code: | {literal}
function fechameses()
{
var d = new Date("{/literal}{$RECORD.invoicedate}{literal}");
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var n = month[d.getMonth()];
}{/literal} |
|
|
Back to top |
|
solidrock Smarty n00b
Joined: 27 Apr 2016 Posts: 2
|
Posted: Wed Apr 27, 2016 11:53 am Post subject: |
|
|
Thanks for replying.. and sorry for being such a noob.
I tried your suggestion but still it would give me blank and not the result.. maybe I am not calling the function correctly... this is what I have so far, What do I need to do to call the function?
<script language="JavaScript" type="text/JavaScript">
{literal}
function fechameses()
{
var d = new Date("{/literal}{$RECORD.invoicedate}{literal}");
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var n = month[d.getMonth()];
}{/literal}
fechameses()
</script>
Thanks for your help! |
|
Back to top |
|
|
|
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
|