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

Smarty 3.0: initial discussion
Goto page Previous  1, 2, 3 ... 5, 6, 7 ... 10, 11, 12  Next
 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
swapo
Smarty Regular


Joined: 04 Apr 2005
Posts: 46
Location: Lübeck, Germany

PostPosted: Mon Nov 07, 2005 12:20 pm    Post subject: Reply with quote

@Swatinem
That's what I meant when I was writing about a meta format.

@Razor's Edge UK
Of course you can work around missing PHP5 functions. But the OOP features aren't
really portable back to PHP4.
Exception handling is one thing I don't want to miss.
Interfaces, a simple "instanceof" and typed arguments are necessary for consistency.

As I said before: It's not a question of "if" but of "when" PHP5 will make it's way
to a huge number of ISPs. Currently there's not one line finished as we're still discussing
the API layout so it's likely that PHP5 is the default version when Smarty 3 is
finished. Beside that, there's still Smarty 2 which is not going to die in the near
future.


Last edited by swapo on Mon Nov 07, 2005 1:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
Razor's Edge UK
Smarty Rookie


Joined: 19 Jul 2005
Posts: 8
Location: Plymouth, Devon, UK

PostPosted: Mon Nov 07, 2005 12:23 pm    Post subject: Reply with quote

I've been lucky enough to only ever work in PHP5. Prior to that it was just local home site playing in PHP4. Now I'm paid to work with PHP5. So backward compatibility is non-existant. And exception handling is great in PHP5!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
c960657
Smarty Regular


Joined: 07 May 2003
Posts: 75
Location: Copenhagen, Denmark

PostPosted: Wed Nov 09, 2005 9:48 am    Post subject: New suggestion: new interpretation of relative paths Reply with quote

Another suggestion for Smarty 3:
When using relative template paths (paths without a leading /) in a template, the path should be treated as relative to the template itself. E.g. if /var/templates/project1/foo/bar.tpl contains {include file="baz.tpl"}, it should include /var/templates/project1/foo/baz.tpl independant of the value of $smarty->template_dir. The reasoning is that a given template may be used in different projects where $smarty->template_dir may differ.

Also, one could argue that absolute template paths should be relative to $smarty->template_dir. Having filesystem-absolute paths in templates is usually bad coding practice, so the "namespace" consisting of paths with a leading slash could be put to better use. If someone wants filesystem-absolute paths, it can still be achieved through a custom resoucetype, "absfile:/usr/local/templates/foo.tpl".

Interpreting relative and absolute paths for non-file resource types should probably be left to the specific resource type implementation.
Back to top
View user's profile Send private message Visit poster's website
Swatinem
Smarty Rookie


Joined: 26 Jan 2005
Posts: 12

PostPosted: Thu Nov 10, 2005 3:32 pm    Post subject: Reply with quote

I thought a little about the Meta Format for templates.
Every Template Element would be a seperate object of types SmartyMetaTag, SmartyMetaVar, SmartyMetaBlock and SmartyMetaText
The SmartyMetaTemplate would contain a list of child objects... The SmartyMetaBlock would also contain a list of child objects.
These SmartyMetaElements implement a function called compile(). The SmartyMetaText would just return the text and the SmartyMetaBlock would first compile all of its childs and then do with its compiled content whatever it wants Very Happy

This would solve a few problems with block nesting and would give a lot more freedom because the Block actually can use its compiled content.

Perhaps we still have to differentiate between SmartyMetaVar's that are for their own or ones that are arguments to a tag.
Back to top
View user's profile Send private message
Swatinem
Smarty Rookie


Joined: 26 Jan 2005
Posts: 12

PostPosted: Wed Dec 21, 2005 11:16 am    Post subject: Reply with quote

It's been a long time. Any new ideas? When do you want to start coding? I would like to help if i can...
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Wed Dec 21, 2005 2:36 pm    Post subject: Reply with quote

There are some things brewing... I'll be announcing some direction early in the new year.
Back to top
View user's profile Send private message Visit poster's website
peekaa
Smarty Rookie


Joined: 05 Sep 2004
Posts: 8

PostPosted: Tue Jan 31, 2006 11:50 am    Post subject: Reply with quote

Well there is my thoughts about that.
100% PHP5. Latest as possible. We have allways smarty 2.x.

Smarty 2.x has all needs you need. There is only 1 thing that can allways be better. Speed. So use PHP5 new things to make smarty3 faster then ever.

Smarty is somehow good, it dont depend on some other package what is some cases in good, and some cases bad. Its not core thing, but still its nice to see when smarty can communicate with other open source projects.

There are some things that comes in future or atleast i think it comes. One thing is encoders and optimizers. Ssme thing as above, its not core thing, but its nice if smarty knows those things. Its just speed thing.

Other thing is AJAX. Actually AJAX has almost nothing to do with template engines, but still its a option to think. Smarty is supposed to make things easyer, why not that part too.

Just some ideas, maybe it helps. Smile
Back to top
View user's profile Send private message
Swatinem
Smarty Rookie


Joined: 26 Jan 2005
Posts: 12

PostPosted: Wed Feb 01, 2006 8:52 am    Post subject: Reply with quote

The only thing i could think of how Smarty could help AJAX is to have an option to send the pages as Content-Type: text/xml. Alternatively you could also add a option to directly gzip the output via Smarty so you dont need to do that yourself. But thats not as important as Content-Type: text/xml oder application/xml or whatever the content type ist.
Back to top
View user's profile Send private message
amagrude
Smarty n00b


Joined: 02 Dec 2004
Posts: 2

PostPosted: Thu Feb 02, 2006 4:18 pm    Post subject: Couple of suggestions... Reply with quote

1. Easier deployment - It would be damn handy to have 'include_path' like functionality for user developed functions, modifiers, filters and templates. We're able to override a function in Smarty2 now and get basically that for templates, but the rest are interwoven with the core Smarty files. It would simplify upgrading and file management if we could (for example) divide our Smarty installation into three discrete directories: Smarty, Formtool, and our developed modifiers, filters and functions.

2. Modifier Array handling - The current calling semantics for modifiers constrain them to only operate on the value of an associative array and preclude operation on the key, to the point of hiding it from the modifier code. This precludes the development of modifiers which operate on arrays - without twisting the syntax into basically RPN format. As an example, the current implementation forces the prototypical array_key_exists wrapper (we must run with security on) to be written so:

{if 'email'|isset:$ErrorVariableList}

instead of the more consistent (and, IMO, intuitive):

{if $ErrorVariableList|isset:'email'}

I don't see a way to do this in a backward compatible way with user developed modifiers, but the existing modifiers could be extended to directly handle arrays.

Andrew
Back to top
View user's profile Send private message
pt2002
Smarty Regular


Joined: 05 May 2003
Posts: 89
Location: Porto, Portugal

PostPosted: Sun Mar 05, 2006 8:48 pm    Post subject: Reply with quote

Are there any news about Smarty 3 ?

Now, with EZComponents an Zend Framework, the only thing missing is a good template engine.

greetings
pt2002
Back to top
View user's profile Send private message
Ruud
Smarty n00b


Joined: 13 Mar 2006
Posts: 2

PostPosted: Tue Mar 14, 2006 9:18 pm    Post subject: Reply with quote

I want to add some things to the XML discussion. The advantages are clear for everybody. However, it doesn't look like Smarty 3 will support XML tags. There is only one reason to not choose for XML, and that's because XML isn't meant for defining loops (etc.), it's meant for defining data. But I don't think anyone would have a problem with that (what are the practical problems?).

Disadvantages like the header footer problem can be easily solved this way:
Code:

<parent on="main" file="frame.xml"><childtree /></parent>

Frame.xml:
Code:

<html><include id="main" /></html>


Another disadvantage is that XML is less flexible than the curly brackets. But an easy to extend model should make everything possible which is possible with the curly brackets.

I've done some projects with Smarty but things that irritated me were:
  • Templates hard to read, containing two languages
  • Templates didn't look clean, not professional.

That last point is important. Smarty is a well known Template engine for PHP. With PHP5, PHP is getting rid of the 'personal home page' image Smile Smarty can play a role in that process. XML tags would help creating a professional template engine. Developers will judge a web language like PHP on tools like a template engine.

I wouldn't write this if I didn't try to create an XML based T.E. myself. I've got an working concept which parses the following XML template files.

data.xml:
Code:
<tpl:page file="frame.xml" on="innerbody">
   <table>
      <tpl:while constraint="$d->next()">
         <tpl:tr style="background: blue;" cycleclass="odd,even">
            <td><tpl:var var="$d->get_name()"/></td>
            <td>Text</td>
         </tpl:tr>
      </tpl:while>
   </table>
   <tpl:foreach from="$test" value="$val">
      <tpl:var var="$val" /><br/>
   </tpl:foreach>
   <form method="post" action="">
      <tpl:input type="text" name="name" />
      <tpl:input type="submit" name="save" />
   </form>
</tpl:page>   


frame.xml
Code:

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <link rel="shortcut icon" href="img/favicon.png" type="image/png" />
      <title>Title</title>
   </head>
   <body>
      <tpl:include id="innerbody" />
   </body>
</html>

This will be compiled to one php file. The file contains the following features:
  • the while, foreach tags and the cycleclass attribute works as expected
  • var outputs an variable
  • tpl:page includes the frame.xml as a parent. (very useful IMHO)
  • the form elements save their value.


It's not easy to develop something like this. I had to write my own Node class, which can be extended from. probably I will develop this further if there won't be any good alternatives.

My point(s):
Why not using XML for smarty? I haven't heard any real good reason, it's possible as you can see, or did I forget something?

Sorry for my not-so-perfect English. Smile
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Mar 14, 2006 10:00 pm    Post subject: Reply with quote

Have you ever handed an XML/XSLT template to a web page designer and watch their eyes glaze over? XML notation is perfect for computer-to-computer data handling, but not well suited for human-edited templates. That is the #1 reason why Smarty templates do not follow XML compliance. Also, since template files are not typically seen/parsed by programs outside of Smarty, it wasn't such a priority either. Now the OUTPUT of the templates can certainly be XML/XHTML compliant, and typically they are.

The one common occurance is HTML editors that complain about tag syntax. The editor is making an assumption that it is editing an HTML file, not an intermediate template file. Sometimes this can be remedied by tags like <!--{ }-->, or configuring the editor for Smarty syntax.

XML compliant templates can have its purpose (even if its for arguments sake), and this may at least be an option... configurable template syntax and/or drop-in compilers. These things are on the list.
Back to top
View user's profile Send private message Visit poster's website
Hielke Hoeve
Smarty Elite


Joined: 06 Jan 2006
Posts: 406
Location: Netherlands

PostPosted: Wed Mar 15, 2006 12:32 pm    Post subject: Reply with quote

Ruud wrote:
I've done some projects with Smarty but things that irritated me were:
  • Templates hard to read, containing two languages
  • Templates didn't look clean, not professional.

That last point is important. Smarty is a well known Template engine for PHP. With PHP5, PHP is getting rid of the 'personal home page' image Smile Smarty can play a role in that process. XML tags would help creating a professional template engine. Developers will judge a web language like PHP on tools like a template engine.

Developers who will judge a web language based on products made (in that language) by others are shortsighted and should stick to the 1 language they know. I have seen alot of crappy products written in PHP but that never kept me back. It even stimulated me to write better code than them.

The personal home page image is all based on the people who write the html code and the html code that comes from the php code. PHP is hardly some kiddy script language, sure even kids can learn to use it but that doesn't mean it's a kiddy script language. The fact that there is WYSIWYG software that can generate php code based on what you drag n drop on the screen doesn't mean the language is bad or less than another.

You are correct that PHP5 is a step upwards but PHP4 has never been small. It worked well and that is what is important.

Ruud wrote:
I wouldn't write this if I didn't try to create an XML based T.E. myself. I've got an working concept which parses the following XML template files.

...

Why not using XML for smarty? I haven't heard any real good reason, it's possible as you can see, or did I forget something?

When looking at your example I get dizzy from trying to extract the html code from the xml code, mainly because both syntaxes look so much alike. Perhaps your view on it is that it gives the templates a neat look, but I find it easier to look for the curly brackets and immediately see that there is a foreach surrounding some html code. If you use a good coding format standard everyone can read the template code with ease. Especially since the Smarty syntax looks like PHP it is easy to learn, and easy to parse into PHP. Which is what, in short, Smarty does. Parsing XML into PHP would take a bit more time, perhaps not very much, but with 100+ templates files I wouldn't dream of changing my template files to XML (even if it wouldn't take long do change) because parsing time will increase too much.

I am currently making software for a company and the manager there doesn't know PHP, he does know HTML, he read the smarty code and understood what I was trying to achieve and even thought the syntax was neat. This shows that even with a little bit of experience people can read the code. If I would write it without Smarty, that is PHP and HTML in the same file Sad Shocked , I am sure he would not understand and leave me to my humble coding. Resulting in needing more time, because certain aspects wouldn't be implemented due to certain design decisions.
_________________
Debug XHTML Compliance
SmartyPaginate
Smarty License Questions
---
(About Unix) The learning curve is full of aha! moments, such as that glorious day that the full beauty of grep and, later, find is revealed in all its majesty. --- Robert Uhl <ruhl@4dv.net>
Back to top
View user's profile Send private message
Ruud
Smarty n00b


Joined: 13 Mar 2006
Posts: 2

PostPosted: Thu Mar 16, 2006 10:01 pm    Post subject: Reply with quote

Quote:
Developers who will judge a web language based on products made (in that language) by others are shortsighted and should stick to the 1 language they know

That's true, but the difference here is that smarty has a subdomain of php.net (smarty.php.net). With that subdomain PHP says 'Smarty is our main Template engine'.That's why Smarty should not get behind in development (I'm not saying it is, that's we're discussing about Wink ).

I think a lot of arguments about this subject depend on taste. A good editor would highlight the different namespaces, curly brackets on the other hand differ enough without highlighting.

Quote:
Parsing XML into PHP would take a bit more time
You mean compiling the templates? I don't understand that would be a problem.. as long as the compiled files are used in production environment.

I'm developing an open-source project for a small company (as a final study assignment) and using PHP for that, I will (re)consider Smarty with the given arguments. Smile
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Mar 17, 2006 1:52 am    Post subject: Reply with quote

I think I've made my points about XML and its (un)suitability already though I will point out that the most promising XMLish approach in my mind is something along the lines of TAL. Unfortunately, that is not XML compliant either as it mangles the attribute space of XML tags.

Re-iterating Monte's comment, a drop-in compiler model seems like a nice compromise -- use any syntax style you want as long as you implement a suitable compiler for your grammer. It seems to me (and I've proposed this before) that this begs for separating the compiler into two distinct parts, namely a front-end and a back-end with an intermediate, generalized and standard format in-between. The front-end compilers (ie: "source compilers") would compile to the intermediate form and the back-end compilers would compile the intermediate form into the desired "object code" (eg: PHP). This also opens the door to optimization strategies as the intermediate format could potentially be analyzed and transformed in various ways. It sounds good on paper but it also seems a little overblown.

Never-the-less, this is one of my favourite ideas as a path to fully modularizing and abstracting Smarty's capabilities. This does leave an open question: what should the intermediate form's data strucuture look like and what is the minimal set of tokens/operations that it would need to support?" The way I phrased that probably suggests a token stack together with associated data hashes for the token data (so everthing can be readily serialized) -- but I suppose other interesting possibilities exist. Then again, it may all be crazy talk Smile
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 -> Smarty Development All times are GMT
Goto page Previous  1, 2, 3 ... 5, 6, 7 ... 10, 11, 12  Next
Page 6 of 12

 
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