Re: Push style templating systems
by perrin (Chancellor) on Mar 14, 2008 at 23:06 UTC
|
"Push" seems like a poor name for this. It doesn't imply anything other than calling the template from perl code, i.e. the same thing I referred to as "pipeline." What makes Template::Recall different is what it lacks: loops and conditionals. I'd refer to it as something like "substitution-only" templating. You could probably count all of the answers to "How can I expand variables in text strings?" while you're at it.
I also wouldn't lump HTML::Seamstress and XMLC in with Template::Recall and StringTemplate. As you know, the former use an approach based on the HTML/XML document structure, while Template::Recall and CGI::FastTemplate do a much simpler regex-like substitutions. | [reply] |
|
I'd refer to it as something like "substitution-only" templating.
One difference is that Template::Recall works on fragments, and the logic for assembling those fragments into a larger document is in the code, not the template. It's not a big thing, but it's different from other template-as-a-whole-document approaches.
| [reply] |
|
| [reply] |
|
|
I guess if you limit the definition of "pipeline" templating to be just
whether a system uses a method call to render the template, then
Template::Recall is a pipeline system.
But I still feel that the term "reverse callback" is appropriate, because
Template::Recall uses template fragments, just as the callback method uses code
fragments. It's this opposite that makes me think the term works. Here's how
my mind assembles the behavior of these two models.
Callback
template
...
--> code
template
--> code
template
...
etc
Template::Recall
code
...
--> template
code
--> template
code
...
etc
where --> is the callback occurance. The "callback" mechanism is essentially an
'eval' (right?), while the "reverse callback" is basically substitution.
I picture a pipeline system more like
code template
... ...
... ...
... --> ...
where the rendering occurs at one time, e.g. HTML::Template->process() after
the the appropriate data structures have been setup.
I'm largely speaking for Template::Recall here, since it takes its name
from "reverse callback". I'm not quite sure that I would call all systems that
work on template fragments reverse callback. Or "push", for that matter, although
both terms work to some degree. "Pipeline" works too, in the narrow definition above,
but doesn't provide much of a distinction.
P.S. My Interent is spotty for the next two days, so I'll try and
respond, if necessary after that.
| [reply] [d/l] [select] |
|
What I was trying to get at when I chose the terms callback and pipeline was the difference in how web requests are typically processed. Tools like Embperl, Mason, and Apache::ASP all want to hand off control to a template immediately, which puts the templates in the driver's seat (i.e. it's more like a complete program than a template). The others require you to run some other program and just call the template tool when you want to generate output.
I wasn't trying to use these terms to separate tools which use in-line code from those that don't. For example, I don't call Text::Template a callback system.
I don't have a trademark on these terms and you're free to use them as you wish, or ignore them completely. I'm just explaining what I had in mind when I wrote that.
| [reply] |
|
|
|
|
"Push" seems like a poor name for this.
Well, what name do you think is best?
I also wouldn't lump HTML::Seamstress and XMLC in with Template::Recall and StringTemplate. As you know, the former use an approach based on the HTML/XML document structure, while Template::Recall and CGI::FastTemplate do a much simpler regex-like substitutions.
If you focus on _how_ they do their job, they are different. If you focus on the fact that they achieve what Terence Parr defined throughout his article, then Template::Recall and HTML::Seamstress are very similar.
And again, with both Recall and Seamstress, you must adhere to a certain discipline while with TT and others you can adhere if you please, but dont have to.
| [reply] |
|
For me, if somebody really wants to make the artificial distinction between push and pipeline that is fine. The template world is so small and I have spent too much time quibbling about this topic in the past. I think the following two concepts frame the debate in more of the light of what it actually is about:
Mini-language vs Variable-swapping-only - This is probably what the debate is about. Where really does the display formatting logic belong? Does it belong in the template with the rest of the display information, or does display formatting logic belong outside of the template. Without a mini-language you have to "push" the display formatting from the perl code. With a mini-language the template can "pull" data it needs.
My chosen template system is better than that "other" template system - It is so easy to be religious about things that are trivial and insignificant, so we let ourselves be. We focus so much on an arbitrary core set of ideas, and we go so far as to treat them as absolutes, that we fail to see the merits of just about anything else. Perhaps we need a name for this system - something such as developer religio-mytopia.
I apologize that this appears here in your node. I just find my self participating in a many lists (perl and non-perl) lately where developers argue a point as if the entire world's outcome was based upon it (only slight hyperbole here). The world of Perl Templating or even General Templating is so small but we treat it like it is the end-all-be-all. Please use what is best for you. Evangelize it even. But artificial distinctions and false absolutes don't help clear things up.
This thread didn't start with the explicit intent of pushing Push over Pipeline, but it seems to have the implied intent, and subsequent replies have only strengthened this argument.
Still ++ for listing the systems that fall into this particular genre.
my @a=qw(random brilliant braindead); print $a[rand(@a)];
| [reply] |
|
|
Template::Recall and CGI::FastTemplate do a much simpler regex-like substitutions.
I think you mean StringTemplate, not CGI::FastTemplate... anyway, StringTemplate requires the Antlr parser generator to work, so I dont think it does simple regex substitutions.
| [reply] |
|
CGI::FastTemplate is a module with a similar approach to Template::Recall. It uses regexes.
| [reply] |
|
|
|
"Push" seems like a poor name for this. It doesn't imply anything other than calling the template from perl code, i.e. the same thing I referred to as "pipeline."
The trick is to look at it from the capabilities of the template not how the template is called. the definitions of push and pull-style rely on what the template can do, not how the template is called.
I also wouldn't lump HTML::Seamstress and XMLC in with Template::Recall and StringTemplate.
From the standpoint of template capabilities given in the definition, you can see why they would be lumped together. However,
| [reply] |
|
I did a bit of googling for push-style and it seems that this is XML terminology based on this article.
| [reply] |
|
| [reply] |
Re: Push style templating systems
by metaperl (Curate) on Mar 14, 2008 at 18:51 UTC
|
From: Oleg Kobchenko <okj@NOSPAM.com>
Subject: Re: [Jgeneral] J's first/leading dynamic HTML generation tool
+, JHP,
is pull-style, object-level and embedded. I am shocked
To: General forum <general@jsoftware.com>
This business of non-Turing templates have been
known in HTML and before that, in GUI in general,
by the name of Data Binding.
In Internet Explorer
http://msdn.microsoft.com/workshop/author/databind/data_binding.asp
In Windows Presentation Foundation
http://msdn2.microsoft.com/en-us/library/ms752347.aspx
Two-way binding in ASP.NET
http://msdn.microsoft.com/msdnmag/issues/06/12/ExtendASPNET/
Windows Forms Data Binding
http://msdn2.microsoft.com/en-us/library/ef2xyb33.aspx
Internet Explorer 4.0-5.0 (1997-98) introduced dynamic two-way
hierarchical binding was first introduced, a very powerful feature,
especially coupled with hierarchical SQL query. HTML could be bound
to XML data islands, which could be fetched from the server without
reloading the page (technology that much later became known as AJAX).
| [reply] [d/l] |
|
Microsoft has moved their data binding link.
| [reply] |
Re: Push style templating systems
by pKai (Priest) on Mar 22, 2008 at 13:55 UTC
|
Parr goes beyond push/pull in his article. The article is titled "Enforcing Strict Model-View Separation in Template Engines".
In his paper he shows that some additions made to "push" are harmless with regard to enforcing model-view separation, i. e. looping and conditionals ("if", but only when you confine to pure boolean testing, no expression evaluation).
He even mentioned HTML::Template as being clean in this respect.
So, while HTML::Template implements looping via its LOOP mini-language control, StringTemplate uses template-recursion for that. Both have, of course, the restricted if, mentioned above. But you list only StringTemplate but not HTML::Template. Why?
Update (2008-03-23 19:25+0000):
Or put the question the other way round (assuming that Rhandom is right, that the point of your list, at least with the Perl part is "no mini-language"): Why do you endorse/mention/include StringTemplate, though it has a mini-language?
| [reply] [d/l] [select] |
|
you list only StringTemplate but not HTML::Template. Why?
I guess because HTML::Template::Expr raises the entanglement index. But pure HTML::Template is definitely push-style. Added.
Or put the question the other way round (assuming that Rhandom is right, that the point of your list, at least with the Perl part is "no mini-language")
When I opened this mode, I stated my purpose. It was to record push-style systems. I don't know why you would figure that Rhandom would know more about my purposes than the ones I stated.
Why do you endorse/mention/include StringTemplate, though it has a mini-language?
Because it meets the criteria for strict separation... I'm starting to see that push-style is not what he used as a term. He did use pull-style when referring to tt/mason-esque systems, but he never used to the term pull style to refer to systems like XMLC, etc.
| [reply] |
|
Thanks for clearing that up, at least somewhat ;-)
- Citing Terence Parr
- The trick is to provide sufficient power in a template engine without providing constructs that allow separation violation.
It is my understanding that he shows that "push" (his Definition 8) is sufficiently strict to ensure separation. But for the template engine user's convenience you can add things while separation is still enforced.
He designed StringTemplate accordingly, but StringTemplate isn't pure-push then, isn't it?
| [reply] [d/l] [select] |
|
|
Actually he does use the term "push strategy" in Definition 8 in Section 7.1
| [reply] |
Mustache: a language-neutral Push style templating system
by metaperl (Curate) on Dec 13, 2010 at 18:33 UTC
|
| [reply] |
Template::Semantic - a new Push style templating system
by metaperl (Curate) on Feb 09, 2010 at 19:32 UTC
|
| [reply] |
HTML::TagTree added to push-style templating list
by metaperl (Curate) on Aug 01, 2011 at 22:01 UTC
|
HTML::TagTree is documented as being able to do flexible HTML
templating. The examples show it doing full documents, but the actual
interplay of this module with HTML in practical settings is
not shown in the docs. Generating HTML de novo is one part of HTML templating -
replacing text and deleting text are the others and I dont see how
this module handles that.
Perhaps with the new wave of all design being delegated to CSS, this purely programmatic approach to HTML generation may in fact be workable. What are typically replacements in common HTML templating would simply be generated on the fly with this module. And deletions are a non-issue as only what is needed is generated.
| [reply] |
Re: Push style templating systems
by metaperl (Curate) on Aug 03, 2009 at 12:17 UTC
|
added XML::TWig to the list of push-style templating systems.
| [reply] |
Re: Push style templating systems
by metaperl (Curate) on Aug 17, 2009 at 13:30 UTC
|
Cindy appears to offer strong separation of code from Perl.
| [reply] |
|
Actually Cindys web engine Cindy::Apache2 (requires mod_perl) is language independent. It takes XML data that can be produced by an apache request handler (static, php, ...) and moves them into a template.
How to move the data is specified in a content injection sheet. This has a <source xpath> action <target xpath> syntax to describe data movements.
This may even qualify as strict separation. I'll check if my module (Cindy, see also http://www.heute-morgen.de/site/10_About.shtml) is actually Parr strict.
| [reply] |
|
I am not shure if I must consider the content injection sheet part of the view. If so I enforce only the most important Parr rule (Do not modify the model). The others can be violated because I use XPath as my mini language.
| [reply] |
Muntjac and Web Elements
by metaperl (Curate) on Apr 02, 2013 at 15:25 UTC
|
| [reply] |
Re: Push style templating systems
by metaperl (Curate) on Feb 19, 2010 at 12:36 UTC
|
| [reply] |
Text::Haml a ruby-inspired Push style templating system
by metaperl (Curate) on Mar 10, 2010 at 21:20 UTC
|
| [reply] |
Matt S Trout has authored a Push style templating system!
by metaperl (Curate) on Mar 18, 2010 at 21:37 UTC
|
HTML::Zoom has been added to the list. Why did he write it?
I just wanted a streaming capable seamstress that I didn't hate the API of :)
How should we refer to him?
please use 'Matt S Trout' for consistency,that's how I sign -everything-
... it's not a big deal, it's just that it makes iteasier for people to connect cpan MSTROUT and IRC mst
| [reply] |
Nes - a new Push style templating system
by metaperl (Curate) on Apr 15, 2010 at 19:09 UTC
|
Nes is short for "No embedded source" - yet it allows for embedding SQL (grin).
| [reply] |
|
Only 'SELECT' statement. Since the template does not modify the application data.
Nes Model:
.----------------------------------------------.
| | Nes Object | |
| '------------' |
| .-------------------. .-----------------. |
| | template.nhtml | | script.pl | |
| |-------------------| |-----------------| |
| | _ |--->| _ _ | |
| | | |<---| | | | |
| '--------|----------' '----|-------|----' |
'----------|--------------------|-------|------'
| | |
| | '------------------.
| | |
v v v
.----------------------. .-----------------------. .------------.
| | | | | |
| Nes Object Library | | My App Perl Library | | CPAN |
| | | | | |
'----------------------' '-----------------------' '------------'
Nes Object:
.------------------------------------------------------------------------------------.
| | Nes Object | |
| '------------' |
| .-----------------------------------. .---------------------------------------. |
| | template.nhtml | | script.pl | |
| |-----------------------------------| |---------------------------------------| |
| | |--->| | |
| | {: Nes 1.0 ('script.pl') :} | | Nes::Singleton->new('template.nhtml') | |
| | |<---| | |
| '-----------------------------------' '---------------------------------------' |
'------------------------------------------------------------------------------------'
Nes Request:
.-------------------------------------------.
| GET or POST HTTP Request |
| http://example.com/template.nhtml |
'-------------------------------------------'
|
v
.-------------------------------------------.
| /cgi-bin/nes/dispatch.cgi |
'-------------------------------------------'
|
v
.-------------------------------------------.
| Nes::Singleton |
|-------------------------------------------|
| new {'CFG'} for this dir |
| new {'top_container '} for template.nhtml |
'-------------------------------------------'
|
v
.-------------------------------------------.
| Nes::Singleton->{'top_container'} |
|-------------------------------------------|
| new {'register'} |
| new {'query'} |
| new {'cookies'} |
| new {'session'} |
| new {'container'} for template.nhtml |
'-------------------------------------------'
|
v
.-------------------------------------------.
| Nes::Singleton->{'container'} | <---.
|-------------------------------------------| |
| get { NES 1.0 ... } line | |
| new {'content_obj'} for this content type | |
'-------------------------------------------' |
| |
v |
.-------------------------------------------. |
| do Perl scripts | |
|-------------------------------------------| |
| Nes::Singleton->out() | |
'-------------------------------------------' |
| |
v |
.-------------------------------------------. |
| Nes::Singleton->{'container'}->interpret | |
'-------------------------------------------' |
| |
v ( interaction )
.---------------------. |
| { include } ? |---{ yes }--------'
'---------------------'
|
{ no }
|
v
.-------------------------------------------.
| print HTTP Headers |
| print the out |
'-------------------------------------------' | [reply] |
Dwoo added to Push style templating systems
by metaperl (Curate) on Apr 22, 2010 at 15:11 UTC
|
Dwoo is a new addition to the list.
| [reply] |
Template Power added to the push-style templating system list
by metaperl (Curate) on Mar 30, 2012 at 14:43 UTC
|
| [reply] |
Re: Push style templating systems
by metaperl (Curate) on Apr 17, 2009 at 15:05 UTC
|
| [reply] |
2 javascript and 1 haskell languaged added to push-style templating systems list
by metaperl (Curate) on Apr 08, 2012 at 12:24 UTC
|
check out the latest additions to the push-style templating list.
| [reply] |
Template::Replace added to Push style templating systems
by metaperl (Curate) on May 01, 2012 at 13:41 UTC
|
| [reply] |
Re: Push style templating systems
by metaperl (Curate) on Mar 18, 2013 at 14:06 UTC
|
Shibari.js has been added to the push-style templating survey.
| [reply] |
Re: Push style templating systems
by metaperl (Curate) on Feb 19, 2010 at 12:23 UTC
|
| [reply] |
Text::Caml added to push style templating systems list
by metaperl (Curate) on Feb 10, 2011 at 14:46 UTC
|
Text::Caml by Viacheslav Tykhanovskyi is similar to Mustache and a new addition to the push-style templating list for Perl.
| [reply] |
Template::Flute added to Push style templating systems list
by metaperl (Curate) on Mar 15, 2011 at 15:11 UTC
|
| [reply] |
HTML::Transmorgify added to Push style templating systems
by metaperl (Curate) on Mar 25, 2011 at 20:18 UTC
|
| [reply] |
Companies using push style templating systems
by metaperl (Curate) on Mar 17, 2008 at 18:25 UTC
|
Here are the companies I know where push-style templating is used:
- Venda an e-commerce house uses push-style. I know cuz I interviewed with them. A very very nice set of people... and all-expenses paid to London. However, I chose my current job because I could extend my skill set.
- Operative is a NYC firm that uses a homegrown push-style system in addition to CGI::Application. I know cuz I interviewed with them 2.
- Arbinger probably uses push-style since James Robson works there.
- My push-style work at Vendare is probably long-gone... they put foot to my ass more than a year ago... running perl/linux out of town with winders and .NET
- There is a company is Washington state that uses XML::LibXML to render HTML so I imagine they qualify as push-style.. I think they are whitepages.com or yellowpages.com --- they require references up front before interviewing, so that was a turn-off for me.
| [reply] |