Strike X Posted November 28, 2008 Share Posted November 28, 2008 Is there any template system allow you to create customs tags? For example: For example, this creates a macro variable that prints a big "Hello Joe!'': <#macro greet person> <font size="+2">Hello ${person}!</font> </#macro> and then you can use this macro as: <@greet person="Fred"/> and <@greet person="Batman"/> Output, This will print on the browser: <font size="+2">Hello Fred!</font> and <font size="+2">Hello Batman!</font> I got this example from freemarker http://freemarker.sourceforge.net/docs/dgui_misc_userdefdir.html (For Java) but I am looking similar to this for PHP, I can't find it. ??? Quote Link to comment https://forums.phpfreaks.com/topic/134588-template-system-customs-tags/ Share on other sites More sharing options...
corbin Posted November 28, 2008 Share Posted November 28, 2008 As far as I know, no template engine in PHP does that. You could probably mod one to do it though. Quote Link to comment https://forums.phpfreaks.com/topic/134588-template-system-customs-tags/#findComment-700842 Share on other sites More sharing options...
Eric_Ryk Posted November 28, 2008 Share Posted November 28, 2008 Although there is nothing that has "macros" this really could be accomplished through sub-templating, ie: putting a template within a template (or loading a template into a variable and then passing that value to another template, either one accomplishes the same thing). Quote Link to comment https://forums.phpfreaks.com/topic/134588-template-system-customs-tags/#findComment-700865 Share on other sites More sharing options...
Strike X Posted November 28, 2008 Author Share Posted November 28, 2008 As far as I know, no template engine in PHP does that. You could probably mod one to do it though. I see, I might try to develop it. Can you please give me some of advice how to implement this? and what PHP functions to use to parse custom tags. Quote Link to comment https://forums.phpfreaks.com/topic/134588-template-system-customs-tags/#findComment-701366 Share on other sites More sharing options...
corbin Posted December 1, 2008 Share Posted December 1, 2008 You'll want to look into the regexp functions. php.net/preg_replace for example Quote Link to comment https://forums.phpfreaks.com/topic/134588-template-system-customs-tags/#findComment-702787 Share on other sites More sharing options...
dclamp Posted December 1, 2008 Share Posted December 1, 2008 I am pretty sure you can do something like that in SMARTY. but i am not 100% Quote Link to comment https://forums.phpfreaks.com/topic/134588-template-system-customs-tags/#findComment-702809 Share on other sites More sharing options...
corbin Posted December 2, 2008 Share Posted December 2, 2008 A template class that I wrote could do it, but it would be ghetto. It would involve lots and lots and lots of unnecessary execution for my code to do it. (It would have to be templates in a template.) Quote Link to comment https://forums.phpfreaks.com/topic/134588-template-system-customs-tags/#findComment-703643 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.