|
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 |
eithe Smarty Rookie
Joined: 15 Oct 2010 Posts: 6
|
Posted: Wed Nov 06, 2013 12:39 pm Post subject: Hyphenated function parameters |
|
|
Hi there,
Recently I need to add hyphenated parameters to my function arguments, ie: for function displayImage, which is used like this:
Code: | {displayImage src="[url_to_img]" alt="[alternate_text]"} |
that outputs:
Code: | <img src="[url_to_img]" alt="[alternate_text]"/> |
Unfortunately this approach won't work with parameters that have hyphens in them, like HTML5 data- attributes (or I've not found a way to do it). At best I'd like to do something like:
Code: | {displayImage src="[url_to_img]" "data-number"=5} |
which would output:
Code: | <img src="[url_to_img]" data-number="5"/> |
Thanks for help! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Nov 07, 2013 1:18 am Post subject: |
|
|
This is supported since Smarty 3.1.9.
The following should work (no quotes at the attribute name]
Code: | {displayImage src="[url_to_img]" data-number=5} |
|
|
Back to top |
|
eithe Smarty Rookie
Joined: 15 Oct 2010 Posts: 6
|
Posted: Fri Nov 08, 2013 8:30 am Post subject: |
|
|
Oh, cheers! I'm using version 3.0.7, so there's the reason for it not working. Good to know there's a solution - now it's only the matter of convincing higher-ups to upgrade smarty version |
|
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
|