We're in the process of selecting a template engine on which to build our own Campsite language compiler. So far we selected two template engines: Smarty and Savant. I would like to start a discution on the merits of these to that should lead to choosing one of them.
I extracted a list of pros and cons for each template engine (see below). Please send your opinions on this subject asap: we should decide which engine to use by the end of this week.
Smarty PROS:
it would take less work to implement the Campsite template engine because Smarty already provides the lex part
has many useful features already implemented: variables, output formatting
CONS:
adds a third language layer: PHP, Campsite lingo and Smarty language
this allows the web designer to do more mistakes:
errors are harder to detect
gives too much control to the web designer
allows the web designer to mix the business logic with layout logic
Savant
PROS:
there are only two language layers: PHP (Savant templates are pure PHP code) and Campsite lingo
by the means of Campsite compiler we can apply constraints to the web designer (not allow him to do whatever he wants)
the Campsite compiler forces the web designer to work only with the layout logic, the business logic is implemented by the compiler
CONS:
it would take more work to implement the Campsite template engine because Savant does not provide anything in this regard
we would have to implement features that Smarty already has implemented
Mugur
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2
Would there be an advantage one way or another in being able to use
existing code or code snippets in one or the other? For example, is there
a repository of code that we could tap into by using Savant as opposed to
Smarty, or vice versa? I seem to recall there being a lot of things that
use Smarty, but maybe my recollection is wrong.
Personally, the reason I ask is that it would be excellent if there was a
way we could use some of the plugins developed for other CMSes.
doug
Mugur Rus
04/11/2006 09:03 PM
Please respond to campsite-dev
To: Campsite Dev
cc:
Subject: [campsite-dev] IMPORTANT for the future of Campsite
Hi all,
We're in the process of selecting a template engine on which to build our
own Campsite language compiler. So far we selected two template engines:
Smarty and Savant. I would like to start a discution on the merits of
these to that should lead to choosing one of them.
I extracted a list of pros and cons for each template engine (see below).
Please send your opinions on this subject asap: we should decide which
engine to use by the end of this week.
Smarty
PROS:
it would take less work to implement the Campsite template engine because
Smarty already provides the lex part
has many useful features already implemented: variables, output formatting
CONS:
adds a third language layer: PHP, Campsite lingo and Smarty language
this allows the web designer to do more mistakes:
errors are harder to detect
gives too much control to the web designer
allows the web designer to mix the business logic with layout logic
Savant
PROS:
there are only two language layers: PHP (Savant templates are pure PHP
code) and Campsite lingo
by the means of Campsite compiler we can apply constraints to the web
designer (not allow him to do whatever he wants)
the Campsite compiler forces the web designer to work only with the layout
logic, the business logic is implemented by the compiler
CONS:
it would take more work to implement the Campsite template engine because
Savant does not provide anything in this regard
we would have to implement features that Smarty already has implemented
Mugur
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2
It's good to be onboard this project. Before I can give you my two
cents, however, I would like to hear exactly what it is we want our
template system to be able to do? I'm only dimly aware from scanning
previous e-mails that we'd like to have our own Campsite lingo. But
what does this entail? Perhaps there is an entry in the documentation
wiki or a previous e-mail I could be directed to.
I've had a lot of experience with phptemplate (in drupal) and PHPLib;
I've had minimal experience with Smarty and no experience with Savant.
I agree with your cons on Smarty; we chose to not use Smarty in
Caravel (http://www.caravelcms.org/) for precisely this reason--it
provided far more than we needed. We didn't want to have to worry
about chasing down Smarty bugs on top of our own bugs, or worry about
a separate programming language.
1. PHPLib (http://www.sanisoft.com/phplib/manual/) is a very simple
templating system similar to a miniature version of Smarty. It can do
basic loops and variable substitutions. Caravel went with PHPLib in
roughly 2000 and has been using it since. Most of the bugs are worked
out by now. I can't do a pros and cons until I understand fully what
it is we want the templating engine to do, but here is a rough
pro/con.
PROS:
(a) Very small and robust.
(b) Separation of presentation from logic layers.
CONS:
(a) Barely maintained; it is fairly old, although a new release came
out this year.
2. phptemplate. I really like phptemplate; although this is mostly
because I really like drupal. There is a lot of flexibility in
phptemplate; but it is also easier to break things.
PROS:
(a) Pure php.
(b) Integrates themes into the code. If you prepend theme_ to a
function, then a theme developer can override your output with their
own theme-based output.
CONS:
(a) Rides on top of drupal.
(b) Easy for the web designer to break the site; blurs logic and
presentation layers.
Those are a couple of cents. Let me know where I can find the
complete needs-specification for the templating system in Campsite and
I may have something more to add on.
Yours faithfully,
Peter Hartman
On 4/11/06, Mugur Rus wrote:
> Hi all,
>
> We're in the process of selecting a template engine on which to build our
> own Campsite language compiler. So far we selected two template engines:
> Smarty and Savant. I would like to start a discution on the merits of these
> to that should lead to choosing one of them.
>
> I extracted a list of pros and cons for each template engine (see below).
> Please send your opinions on this subject asap: we should decide which
> engine to use by the end of this week.
>
> Smarty
> PROS:
>
> it would take less work to implement the Campsite template engine because
> Smarty already provides the lex part
> has many useful features already implemented: variables, output formatting
> CONS:
>
> adds a third language layer: PHP, Campsite lingo and Smarty language
>
> this allows the web designer to do more mistakes:
>
> errors are harder to detect
>
> gives too much control to the web designer
> allows the web designer to mix the business logic with layout logic
> Savant
> PROS:
>
> there are only two language layers: PHP (Savant templates are pure PHP code)
> and Campsite lingo
> by the means of Campsite compiler we can apply constraints to the web
> designer (not allow him to do whatever he wants)
> the Campsite compiler forces the web designer to work only with the layout
> logic, the business logic is implemented by the compiler
> CONS:
>
> it would take more work to implement the Campsite template engine because
> Savant does not provide anything in this regard
> we would have to implement features that Smarty already has implemented
> Mugur
>
>
> ________________________________
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
> countries) for 2
Looks like you're tackling some very interesting problems there.
Recently I've had exposure to some parser/lexer related issues myself in
some of my modelling work (not with the fashionistas, alas: the
engineering/mathematics type). I have been writing SWIG-wrappers for
some code, and I have been involved with an open source mathematical
modelling package that parses 'model' documents into memory, then solves
them using various algorithms.
One idea that occurs to me from this experience is that you could
implement the campsite engine as a php extension module (like the mysqli
module, etc). This would have various functions to allow the display of
articles, fetching lists, reading metadata, etc.
Next, starting with the current Campsite parser, you could modify it so
that instead of working like an interpreter, it works as a language
translator, taking campsite template syntax as input, then giving *pure
PHP* as output. This would then be easily verifiable: you could have a
test suite to ensure that all the basic syntax transformations worked
before you actually starting running the templates. The generated PHP
would of course be heavily dependent on the PHP commands
('show_article', 'list_sections' etc) from your campsite
php-extension-module. You might consider implementing the translator
using ANTLR, alternatively -- this is supposedly very nice to work with.
This approach would leave you able to use the exact same templates as
currently. You would maintain complete control of what syntax was
permissible, but it would be simple to allow php to 'pass through' the
translator -- for using stuff like phorum code, etc -- if that were
desired. I think it would be very fast too, since at runtime, the
campsite parser wouldn't be used at all, only the php parser and your
php extension module.
I'm not in a position to really participate in this at the moment, but I
thought it would be interesting to give you my thoughts. Hope it goes well.
Cheers
JP
Mugur Rus wrote:
> Hi all,
>
> We're in the process of selecting a template engine on which to build
> our own Campsite language compiler. So far we selected two template
> engines: Smarty and Savant. I would like to start a discution on the
> merits of these to that should lead to choosing one of them.
>
> I extracted a list of pros and cons for each template engine (see
> below). Please send your opinions on this subject asap: we should
> decide which engine to use by the end of this week.
>
> Smarty
> PROS:
>
> * it would take less work to implement the Campsite template
> engine because Smarty already provides the lex part
>
> * has many useful features already implemented: variables, output
> formatting
>
> CONS:
>
> *
> adds a third language layer: PHP, Campsite lingo and Smarty language
> o
> this allows the web designer to do more mistakes:
> o
> errors are harder to detect
>
> *
> gives too much control to the web designer
> *
> allows the web designer to mix the business logic with layout logic
>
> Savant
> PROS:
>
> *
> there are only two language layers: PHP (Savant templates are
> pure PHP code) and Campsite lingo
> *
> by the means of Campsite compiler we can apply constraints to
> the web designer (not allow him to do whatever he wants)
> *
> the Campsite compiler forces the web designer to work only with
> the layout logic, the business logic is implemented by the compiler
>
> CONS:
>
> *
> it would take more work to implement the Campsite template
> engine because Savant does not provide anything in this regard
> *
> we would have to implement features that Smarty already has
> implemented
>
> Mugur
>
> ------------------------------------------------------------------------
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls
>
> to the US (and 30+ countries) for 2
As you can see it's completely different from PHP: no objects, no classes, functions or variables. Just "list article", "list section", "print article author" etc. Of course, this ties the template engine to Campsite, it can't be used in other CMSes. The only problem we have right now is that it is not easily extensible but we want to fix that with the rewriting of the template engine in PHP.
Regards,
Mugur
Peter Hartman wrote: Hi Mugur et al.,
It's good to be onboard this project. Before I can give you my two
cents, however, I would like to hear exactly what it is we want our
template system to be able to do? I'm only dimly aware from scanning
previous e-mails that we'd like to have our own Campsite lingo. But
what does this entail? Perhaps there is an entry in the documentation
wiki or a previous e-mail I could be directed to.
I've had a lot of experience with phptemplate (in drupal) and PHPLib;
I've had minimal experience with Smarty and no experience with Savant.
I agree with your cons on Smarty; we chose to not use Smarty in
Caravel (http://www.caravelcms.org/) for precisely this reason--it
provided far more than we needed. We didn't want to have to worry
about chasing down Smarty bugs on top of our own bugs, or worry about
a separate programming language.
1. PHPLib (http://www.sanisoft.com/phplib/manual/) is a very simple
templating system similar to a miniature version of Smarty. It can do
basic loops and variable substitutions. Caravel went with PHPLib in
roughly 2000 and has been using it since. Most of the bugs are worked
out by now. I can't do a pros and cons until I understand fully what
it is we want the templating engine to do, but here is a rough
pro/con.
PROS:
(a) Very small and robust.
(b) Separation of presentation from logic layers.
CONS:
(a) Barely maintained; it is fairly old, although a new release came
out this year.
2. phptemplate. I really like phptemplate; although this is mostly
because I really like drupal. There is a lot of flexibility in
phptemplate; but it is also easier to break things.
PROS:
(a) Pure php.
(b) Integrates themes into the code. If you prepend theme_ to a
function, then a theme developer can override your output with their
own theme-based output.
CONS:
(a) Rides on top of drupal.
(b) Easy for the web designer to break the site; blurs logic and
presentation layers.
Those are a couple of cents. Let me know where I can find the
complete needs-specification for the templating system in Campsite and
I may have something more to add on.
Yours faithfully,
Peter Hartman
On 4/11/06, Mugur Rus wrote:
> Hi all,
>
> We're in the process of selecting a template engine on which to build our
> own Campsite language compiler. So far we selected two template engines:
> Smarty and Savant. I would like to start a discution on the merits of these
> to that should lead to choosing one of them.
>
> I extracted a list of pros and cons for each template engine (see below).
> Please send your opinions on this subject asap: we should decide which
> engine to use by the end of this week.
>
> Smarty
> PROS:
>
> it would take less work to implement the Campsite template engine because
> Smarty already provides the lex part
> has many useful features already implemented: variables, output formatting
> CONS:
>
> adds a third language layer: PHP, Campsite lingo and Smarty language
>
> this allows the web designer to do more mistakes:
>
> errors are harder to detect
>
> gives too much control to the web designer
> allows the web designer to mix the business logic with layout logic
> Savant
> PROS:
>
> there are only two language layers: PHP (Savant templates are pure PHP code)
> and Campsite lingo
> by the means of Campsite compiler we can apply constraints to the web
> designer (not allow him to do whatever he wants)
> the Campsite compiler forces the web designer to work only with the layout
> logic, the business logic is implemented by the compiler
> CONS:
>
> it would take more work to implement the Campsite template engine because
> Savant does not provide anything in this regard
> we would have to implement features that Smarty already has implemented
> Mugur
>
>
> ________________________________
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
> countries) for 2�/min or less.
>
>
PHP module is out of question, we don't want functions, classes, objects etc. in our template language. The web designer should not bother with this kind of things. The old "list article", "print article author" etc. are here to stay. Also, PHP functions can't implement statements like this: "list article publish_date greater [date]" because in functions parameters are assigned values, you can't use comparison operators between parameters and values.
The Campsite template engine will work as a language translator: it will generate PHP code from Campsite lingo.
Mugur
John Pye wrote: Hi Mugur
Looks like you're tackling some very interesting problems there.
Recently I've had exposure to some parser/lexer related issues myself in
some of my modelling work (not with the fashionistas, alas: the
engineering/mathematics type). I have been writing SWIG-wrappers for
some code, and I have been involved with an open source mathematical
modelling package that parses 'model' documents into memory, then solves
them using various algorithms.
One idea that occurs to me from this experience is that you could
implement the campsite engine as a php extension module (like the mysqli
module, etc). This would have various functions to allow the display of
articles, fetching lists, reading metadata, etc.
Next, starting with the current Campsite parser, you could modify it so
that instead of working like an interpreter, it works as a language
translator, taking campsite template syntax as input, then giving *pure
PHP* as output. This would then be easily verifiable: you could have a
test suite to ensure that all the basic syntax transformations worked
before you actually starting running the templates. The generated PHP
would of course be heavily dependent on the PHP commands
('show_article', 'list_sections' etc) from your campsite
php-extension-module. You might consider implementing the translator
using ANTLR, alternatively -- this is supposedly very nice to work with.
This approach would leave you able to use the exact same templates as
currently. You would maintain complete control of what syntax was
permissible, but it would be simple to allow php to 'pass through' the
translator -- for using stuff like phorum code, etc -- if that were
desired. I think it would be very fast too, since at runtime, the
campsite parser wouldn't be used at all, only the php parser and your
php extension module.
I'm not in a position to really participate in this at the moment, but I
thought it would be interesting to give you my thoughts. Hope it goes well.
Cheers
JP
Mugur Rus wrote:
> Hi all,
>
> We're in the process of selecting a template engine on which to build
> our own Campsite language compiler. So far we selected two template
> engines: Smarty and Savant. I would like to start a discution on the
> merits of these to that should lead to choosing one of them.
>
> I extracted a list of pros and cons for each template engine (see
> below). Please send your opinions on this subject asap: we should
> decide which engine to use by the end of this week.
>
> Smarty
> PROS:
>
> * it would take less work to implement the Campsite template
> engine because Smarty already provides the lex part
>
> * has many useful features already implemented: variables, output
> formatting
>
> CONS:
>
> *
> adds a third language layer: PHP, Campsite lingo and Smarty language
> o
> this allows the web designer to do more mistakes:
> o
> errors are harder to detect
>
> *
> gives too much control to the web designer
> *
> allows the web designer to mix the business logic with layout logic
>
> Savant
> PROS:
>
> *
> there are only two language layers: PHP (Savant templates are
> pure PHP code) and Campsite lingo
> *
> by the means of Campsite compiler we can apply constraints to
> the web designer (not allow him to do whatever he wants)
> *
> the Campsite compiler forces the web designer to work only with
> the layout logic, the business logic is implemented by the compiler
>
> CONS:
>
> *
> it would take more work to implement the Campsite template
> engine because Savant does not provide anything in this regard
> *
> we would have to implement features that Smarty already has
> implemented
>
> Mugur
>
> ------------------------------------------------------------------------
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls
>
> to the US (and 30+ countries) for 2�/min or less.
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
By using Smarty or Savant we implicitly can benefit from any plugin available for one of these template engines. It seems Smarty has a huge library of plugins available so that would be an advantage. But as I said in my first email having three layers of languages (PHP, Smarty, Campsite) allows the web designer to make mistakes easier and makes the error detection much harder.
Mugur
Douglas.Arellanes@mdlf.org wrote: Would there be an advantage one way or another in being able to use existing code or code snippets in one or the other? For example, is there a repository of code that we could tap into by using Savant as opposed to Smarty, or vice versa? I seem to recall there being a lot of things that use Smarty, but maybe my recollection is wrong.
Personally, the reason I ask is that it would be excellent if there was a way we could use some of the plugins developed for other CMSes.
doug
Mugur Rus 04/11/2006 09:03 PM
Please respond to campsite-dev
To: Campsite Dev
cc:
Subject: [campsite-dev] IMPORTANT for the future of Campsite
Hi all,
We're in the process of selecting a template engine on which to build our own Campsite language compiler. So far we selected two template engines: Smarty and Savant. I would like to start a discution on the merits of these to that should lead to choosing one of them.
I extracted a list of pros and cons for each template engine (see below). Please send your opinions on this subject asap: we should decide which engine to use by the end of this week.
Smarty
PROS:
it would take less work to implement the Campsite template engine because Smarty already provides the lex part
has many useful features already implemented: variables, output formatting
CONS:
adds a third language layer: PHP, Campsite lingo and Smarty language
this allows the web designer to do more mistakes:
errors are harder to detect
gives too much control to the web designer
allows the web designer to mix the business logic with layout logic
Savant
PROS:
there are only two language layers: PHP (Savant templates are pure PHP code) and Campsite lingo
by the means of Campsite compiler we can apply constraints to the web designer (not allow him to do whatever he wants)
the Campsite compiler forces the web designer to work only with the layout logic, the business logic is implemented by the compiler
CONS:
it would take more work to implement the Campsite template engine because Savant does not provide anything in this regard
we would have to implement features that Smarty already has implemented
Mugur
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2�/min or less.
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
The old syntax can change as long as it can be automatically converted
from the old to the new.
2) It needs to support arbitary variables, loops, conditionals, and
boolean expressions.
3) It needs to be in PHP.
4) You should be allowed to write PHP directly inside the templates
without any problems. In other words, you shouldnt be locked in to
only using only Campsite statements.
5) At some level we need to implement caching of the frontend web
pages. This needs to be either in the template engine itself, or in
another layer. The PHP backend administration needs to be able to
signal this caching layer that it needs to refresh. Probably the best
thing to use here would be APC (Alternative PHP Cache: http://ie2.php.net/apc). APC would be optional for the end user,
since it requires compiling an Apache module.
To John:
------------
Both PHP template engines (Smarty and Savant) work as you describe:
they take the template langugage and convert it to PHP, then execute
the PHP.
To Mugur:
------------
I wouldnt say that if we were using Smarty there are 3
languages/layers. Since we would be implementing the Campsite lingo
as extensions to Smarty, then its just smarty with extensions. The
Campsite stuff isnt really "on top of" smarty, but is "part of"
smarty.
But it should be pointed out that we would have to improve the
debugger output for Smarty, cause it sucks. For Savant, looks like we
would have to implement a debugger from scratch.
Another PRO for Smarty is that it has better documentation. Theres
even a book on it.
I'm going to do some more research on Savant todayand get back to you.
- Paul
On 4/12/06, John Pye wrote:
> Hi Mugur
>
> Looks like you're tackling some very interesting problems there.
> Recently I've had exposure to some parser/lexer related issues myself in
> some of my modelling work (not with the fashionistas, alas: the
> engineering/mathematics type). I have been writing SWIG-wrappers for
> some code, and I have been involved with an open source mathematical
> modelling package that parses 'model' documents into memory, then solves
> them using various algorithms.
>
> One idea that occurs to me from this experience is that you could
> implement the campsite engine as a php extension module (like the mysqli
> module, etc). This would have various functions to allow the display of
> articles, fetching lists, reading metadata, etc.
>
> Next, starting with the current Campsite parser, you could modify it so
> that instead of working like an interpreter, it works as a language
> translator, taking campsite template syntax as input, then giving *pure
> PHP* as output. This would then be easily verifiable: you could have a
> test suite to ensure that all the basic syntax transformations worked
> before you actually starting running the templates. The generated PHP
> would of course be heavily dependent on the PHP commands
> ('show_article', 'list_sections' etc) from your campsite
> php-extension-module. You might consider implementing the translator
> using ANTLR, alternatively -- this is supposedly very nice to work with.
>
> This approach would leave you able to use the exact same templates as
> currently. You would maintain complete control of what syntax was
> permissible, but it would be simple to allow php to 'pass through' the
> translator -- for using stuff like phorum code, etc -- if that were
> desired. I think it would be very fast too, since at runtime, the
> campsite parser wouldn't be used at all, only the php parser and your
> php extension module.
>
> I'm not in a position to really participate in this at the moment, but I
> thought it would be interesting to give you my thoughts. Hope it goes well.
>
> Cheers
> JP
>
> Mugur Rus wrote:
>
> > Hi all,
> >
> > We're in the process of selecting a template engine on which to build
> > our own Campsite language compiler. So far we selected two template
> > engines: Smarty and Savant. I would like to start a discution on the
> > merits of these to that should lead to choosing one of them.
> >
> > I extracted a list of pros and cons for each template engine (see
> > below). Please send your opinions on this subject asap: we should
> > decide which engine to use by the end of this week.
> >
> > Smarty
> > PROS:
> >
> > * it would take less work to implement the Campsite template
> > engine because Smarty already provides the lex part
> >
> > * has many useful features already implemented: variables, output
> > formatting
> >
> > CONS:
> >
> > *
> > adds a third language layer: PHP, Campsite lingo and Smarty language
> > o
> > this allows the web designer to do more mistakes:
> > o
> > errors are harder to detect
> >
> > *
> > gives too much control to the web designer
> > *
> > allows the web designer to mix the business logic with layout logic
> >
> > Savant
> > PROS:
> >
> > *
> > there are only two language layers: PHP (Savant templates are
> > pure PHP code) and Campsite lingo
> > *
> > by the means of Campsite compiler we can apply constraints to
> > the web designer (not allow him to do whatever he wants)
> > *
> > the Campsite compiler forces the web designer to work only with
> > the layout logic, the business logic is implemented by the compiler
> >
> > CONS:
> >
> > *
> > it would take more work to implement the Campsite template
> > engine because Savant does not provide anything in this regard
> > *
> > we would have to implement features that Smarty already has
> > implemented
> >
> > Mugur
> >
> > ------------------------------------------------------------------------
> > Yahoo! Messenger with Voice. Make PC-to-Phone Calls
> >
> > to the US (and 30+ countries) for 2
Perhaps I didn't explain my idea very well. The idea I has was that you
would use the same campsite templates as you currently to, for example:
| |
|
|||
||
But then, instead of the campsite parser acting as an interpreter and
executing the template, you would write a parser that simply
*translated* the template into something like this:
Now, when it comes time to run your template, you simply
dl('campsite.so') then require_once("cached_php_output.php"). This would
use your 'campsite.so' PHP extension module to do all the hard work.
You can implement the runtime functionality either using an extension
module (as suggested above, which would allow you to reuse a lot of your
current C code) or using PHP syntax (which is probably what you're
looking at doing in the Smarty case).
The approach I'm suggesting is basically equivalent to using a
specialist parser, build maybe with ANTLR or something like that,
instead of the Smarty engine. Adding new language features would be
rebuilding the translator, but would not necessarily mean writing any
new C code, since it's finally PHP that is being executed, in the form
of translator output.
Your web designers wouldn't see any of this happening. As currently,
they would only see the campsite templates, then the final HTML output.
Your example "" would
perhaps be translated into something like
Mugur Rus wrote:
> Hi John,
>
> PHP module is out of question, we don't want functions, classes,
> objects etc. in our template language. The web designer should not
> bother with this kind of things. The old "list article", "print
> article author" etc. are here to stay. Also, PHP functions can't
> implement statements like this: "list article publish_date greater
> [date]" because in functions parameters are assigned values, you can't
> use comparison operators between parameters and values.
>
> The Campsite template engine will work as a language translator: it
> will generate PHP code from Campsite lingo.
>
> Mugur
>
> */John Pye /* wrote:
>
> Hi Mugur
>
> Looks like you're tackling some very interesting problems there.
> Recently I've had exposure to some parser/lexer related issues
> myself in
> some of my modelling work (not with the fashionistas, alas: the
> engineering/mathematics type). I have been writing SWIG-wrappers for
> some code, and I have been involved with an open source mathematical
> modelling package that parses 'model' documents into memory, then
> solves
> them using various algorithms.
>
> One idea that occurs to me from this experience is that you could
> implement the campsite engine as a php extension module (like the
> mysqli
> module, etc). This would have various functions to allow the
> display of
> articles, fetching lists, reading metadata, etc.
>
> Next, starting with the current Campsite parser, you could modify
> it so
> that instead of working like an interpreter, it works as a language
> translator, taking campsite template syntax as input, then giving
> *pure
> PHP* as output. This would then be easily verifiable: you could have a
> test suite to ensure that all the basic syntax transformations worked
> before you actually starting running the templates. The generated PHP
> would of course be heavily dependent on the PHP commands
> ('show_article', 'list_sections' etc) from your campsite
> php-extension-module. You might consider implementing the translator
> using ANTLR, alternatively -- this is supposedly very nice to work
> with.
>
> This approach would leave you able to use the exact same templates as
> currently. You would maintain complete control of what syntax was
> permissible, but it would be simple to allow php to 'pass through' the
> translator -- for using stuff like phorum code, etc -- if that were
> desired. I think it would be very fast too, since at runtime, the
> campsite parser wouldn't be used at all, only the php parser and your
> php extension module.
>
> I'm not in a position to really participate in this at the moment,
> but I
> thought it would be interesting to give you my thoughts. Hope it
> goes well.
>
> Cheers
> JP
>
> Mugur Rus wrote:
>
> > Hi all,
> >
> > We're in the process of selecting a template engine on which to
> build
> > our own Campsite language compiler. So far we selected two template
> > engines: Smarty and Savant. I would like to start a discution on the
> > merits of these to that should lead to choosing one of them.
> >
> > I extracted a list of pros and cons for each template engine (see
> > below). Please send your opinions on this subject asap: we should
> > decide which engine to use by the end of this week.
> >
> > Smarty
> > PROS:
> >
> > * it would take less work to implement the Campsite template
> > engine because Smarty already provides the lex part
> >
> > * has many useful features already implemented: variables, output
> > formatting
> >
> > CONS:
> >
> > *
> > adds a third language layer: PHP, Campsite lingo and Smarty language
> > o
> > this allows the web designer to do more mistakes:
> > o
> > errors are harder to detect
> >
> > *
> > gives too much control to the web designer
> > *
> > allows the web designer to mix the business logic with layout logic
> >
> > Savant
> > PROS:
> >
> > *
> > there are only two language layers: PHP (Savant templates are
> > pure PHP code) and Campsite lingo
> > *
> > by the means of Campsite compiler we can apply constraints to
> > the web designer (not allow him to do whatever he wants)
> > *
> > the Campsite compiler forces the web designer to work only with
> > the layout logic, the business logic is implemented by the compiler
> >
> > CONS:
> >
> > *
> > it would take more work to implement the Campsite template
> > engine because Savant does not provide anything in this regard
> > *
> > we would have to implement features that Smarty already has
> > implemented
> >
> > Mugur
> >
> >
> ------------------------------------------------------------------------
> > Yahoo! Messenger with Voice. Make PC-to-Phone Calls
> >
> > to the US (and 30+ countries) for 2�/min or less.
>
>
> ------------------------------------------------------------------------
> New Yahoo! Messenger with Voice. Call regular phones from your PC
>
> and save big.
This does make your idea clearer BUT the issue we want to solve is to get rid of any C/C++ code. Campsite will be 100% PHP. A PHP module means we'll have C code that has to be compiled and that's not acceptable.
Mugur
John Pye wrote: Hi Mugur,
Perhaps I didn't explain my idea very well. The idea I has was that you
would use the same campsite templates as you currently to, for example:
| |
|
|||
||
But then, instead of the campsite parser acting as an interpreter and
executing the template, you would write a parser that simply
*translated* the template into something like this:
Now, when it comes time to run your template, you simply
dl('campsite.so') then require_once("cached_php_output.php"). This would
use your 'campsite.so' PHP extension module to do all the hard work.
You can implement the runtime functionality either using an extension
module (as suggested above, which would allow you to reuse a lot of your
current C code) or using PHP syntax (which is probably what you're
looking at doing in the Smarty case).
The approach I'm suggesting is basically equivalent to using a
specialist parser, build maybe with ANTLR or something like that,
instead of the Smarty engine. Adding new language features would be
rebuilding the translator, but would not necessarily mean writing any
new C code, since it's finally PHP that is being executed, in the form
of translator output.
Your web designers wouldn't see any of this happening. As currently,
they would only see the campsite templates, then the final HTML output.
Your example "" would
perhaps be translated into something like
Mugur Rus wrote:
> Hi John,
>
> PHP module is out of question, we don't want functions, classes,
> objects etc. in our template language. The web designer should not
> bother with this kind of things. The old "list article", "print
> article author" etc. are here to stay. Also, PHP functions can't
> implement statements like this: "list article publish_date greater
> [date]" because in functions parameters are assigned values, you can't
> use comparison operators between parameters and values.
>
> The Campsite template engine will work as a language translator: it
> will generate PHP code from Campsite lingo.
>
> Mugur
>
> */John Pye /* wrote:
>
> Hi Mugur
>
> Looks like you're tackling some very interesting problems there.
> Recently I've had exposure to some parser/lexer related issues
> myself in
> some of my modelling work (not with the fashionistas, alas: the
> engineering/mathematics type). I have been writing SWIG-wrappers for
> some code, and I have been involved with an open source mathematical
> modelling package that parses 'model' documents into memory, then
> solves
> them using various algorithms.
>
> One idea that occurs to me from this experience is that you could
> implement the campsite engine as a php extension module (like the
> mysqli
> module, etc). This would have various functions to allow the
> display of
> articles, fetching lists, reading metadata, etc.
>
> Next, starting with the current Campsite parser, you could modify
> it so
> that instead of working like an interpreter, it works as a language
> translator, taking campsite template syntax as input, then giving
> *pure
> PHP* as output. This would then be easily verifiable: you could have a
> test suite to ensure that all the basic syntax transformations worked
> before you actually starting running the templates. The generated PHP
> would of course be heavily dependent on the PHP commands
> ('show_article', 'list_sections' etc) from your campsite
> php-extension-module. You might consider implementing the translator
> using ANTLR, alternatively -- this is supposedly very nice to work
> with.
>
> This approach would leave you able to use the exact same templates as
> currently. You would maintain complete control of what syntax was
> permissible, but it would be simple to allow php to 'pass through' the
> translator -- for using stuff like phorum code, etc -- if that were
> desired. I think it would be very fast too, since at runtime, the
> campsite parser wouldn't be used at all, only the php parser and your
> php extension module.
>
> I'm not in a position to really participate in this at the moment,
> but I
> thought it would be interesting to give you my thoughts. Hope it
> goes well.
>
> Cheers
> JP
>
> Mugur Rus wrote:
>
> > Hi all,
> >
> > We're in the process of selecting a template engine on which to
> build
> > our own Campsite language compiler. So far we selected two template
> > engines: Smarty and Savant. I would like to start a discution on the
> > merits of these to that should lead to choosing one of them.
> >
> > I extracted a list of pros and cons for each template engine (see
> > below). Please send your opinions on this subject asap: we should
> > decide which engine to use by the end of this week.
> >
> > Smarty
> > PROS:
> >
> > * it would take less work to implement the Campsite template
> > engine because Smarty already provides the lex part
> >
> > * has many useful features already implemented: variables, output
> > formatting
> >
> > CONS:
> >
> > *
> > adds a third language layer: PHP, Campsite lingo and Smarty language
> > o
> > this allows the web designer to do more mistakes:
> > o
> > errors are harder to detect
> >
> > *
> > gives too much control to the web designer
> > *
> > allows the web designer to mix the business logic with layout logic
> >
> > Savant
> > PROS:
> >
> > *
> > there are only two language layers: PHP (Savant templates are
> > pure PHP code) and Campsite lingo
> > *
> > by the means of Campsite compiler we can apply constraints to
> > the web designer (not allow him to do whatever he wants)
> > *
> > the Campsite compiler forces the web designer to work only with
> > the layout logic, the business logic is implemented by the compiler
> >
> > CONS:
> >
> > *
> > it would take more work to implement the Campsite template
> > engine because Savant does not provide anything in this regard
> > *
> > we would have to implement features that Smarty already has
> > implemented
> >
> > Mugur
> >
> >
> ------------------------------------------------------------------------
> > Yahoo! Messenger with Voice. Make PC-to-Phone Calls
> >
> > to the US (and 30+ countries) for 2�/min or less.
>
>
> ------------------------------------------------------------------------
> New Yahoo! Messenger with Voice. Call regular phones from your PC
>
> and save big.
---------------------------------
How low will we go? Check out Yahoo! Messenger
Ok, I've taken a look at Savant - i went straight to the source code
to get to the heart of the matter. However, Savant doesnt seem to be
much of anything at all. Its an almost just an interface, with not
much behind it. While an interface is useful for templating purposes,
it doesnt give us any infrastructure to build on. We would basically
be starting from scratch. I could re-write the entire Savant library
in no time at all now that I know what it does.
Given the above I would suggest we go with Smarty.
- Paul
On 4/11/06, Mugur Rus wrote:
> Hi all,
>
> We're in the process of selecting a template engine on which to build our
> own Campsite language compiler. So far we selected two template engines:
> Smarty and Savant. I would like to start a discution on the merits of these
> to that should lead to choosing one of them.
>
> I extracted a list of pros and cons for each template engine (see below).
> Please send your opinions on this subject asap: we should decide which
> engine to use by the end of this week.
>
> Smarty
> PROS:
>
> it would take less work to implement the Campsite template engine because
> Smarty already provides the lex part
> has many useful features already implemented: variables, output formatting
> CONS:
>
> adds a third language layer: PHP, Campsite lingo and Smarty language
>
> this allows the web designer to do more mistakes:
>
> errors are harder to detect
>
> gives too much control to the web designer
> allows the web designer to mix the business logic with layout logic
> Savant
> PROS:
>
> there are only two language layers: PHP (Savant templates are pure PHP code)
> and Campsite lingo
> by the means of Campsite compiler we can apply constraints to the web
> designer (not allow him to do whatever he wants)
> the Campsite compiler forces the web designer to work only with the layout
> logic, the business logic is implemented by the compiler
> CONS:
>
> it would take more work to implement the Campsite template engine because
> Savant does not provide anything in this regard
> we would have to implement features that Smarty already has implemented
> Mugur
>
>
> ________________________________
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
> countries) for 2
I agree with you, in fact I don't know why they call PHPTemplate, Savant and other APIs like that "template engines" Still, it doesn't mean that we'll save a lot of work with Smarty. We'll have to build our own compiler functions, but we won't have to write a lex too, so we'll save something like 10% of the work.
Mugur
Paul Baranowski wrote: Ok, I've taken a look at Savant - i went straight to the source code
to get to the heart of the matter. However, Savant doesnt seem to be
much of anything at all. Its an almost just an interface, with not
much behind it. While an interface is useful for templating purposes,
it doesnt give us any infrastructure to build on. We would basically
be starting from scratch. I could re-write the entire Savant library
in no time at all now that I know what it does.
Given the above I would suggest we go with Smarty.
- Paul
On 4/11/06, Mugur Rus wrote:
> Hi all,
>
> We're in the process of selecting a template engine on which to build our
> own Campsite language compiler. So far we selected two template engines:
> Smarty and Savant. I would like to start a discution on the merits of these
> to that should lead to choosing one of them.
>
> I extracted a list of pros and cons for each template engine (see below).
> Please send your opinions on this subject asap: we should decide which
> engine to use by the end of this week.
>
> Smarty
> PROS:
>
> it would take less work to implement the Campsite template engine because
> Smarty already provides the lex part
> has many useful features already implemented: variables, output formatting
> CONS:
>
> adds a third language layer: PHP, Campsite lingo and Smarty language
>
> this allows the web designer to do more mistakes:
>
> errors are harder to detect
>
> gives too much control to the web designer
> allows the web designer to mix the business logic with layout logic
> Savant
> PROS:
>
> there are only two language layers: PHP (Savant templates are pure PHP code)
> and Campsite lingo
> by the means of Campsite compiler we can apply constraints to the web
> designer (not allow him to do whatever he wants)
> the Campsite compiler forces the web designer to work only with the layout
> logic, the business logic is implemented by the compiler
> CONS:
>
> it would take more work to implement the Campsite template engine because
> Savant does not provide anything in this regard
> we would have to implement features that Smarty already has implemented
> Mugur
>
>
> ________________________________
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
> countries) for 2�/min or less.
>
>
---------------------------------
How low will we go? Check out Yahoo! Messenger
At 10:31 12.04.2006, Mugur Rus wrote:
>By using Smarty or Savant we implicitly can benefit from any plugin
>available for one of these template engines. It seems Smarty has a huge
>library of plugins available so that would be an advantage. But as I said
>in my first email having three layers of languages (PHP, Smarty, Campsite)
>allows the web designer to make mistakes easier and makes the error
>detection much harder.
but wouldn't it be an advantage for campsite if using smarty that third
party applications could be integrated much easier - if they used smarty in
the first place?
sure, there would be a third logic involved, the smarty way of doing
things, but ... let me think of an example ... if there is a library that
reads MP3 metatags from files on the server and returns an array for some
smarty template to be displayed - to make this into a plugin would only
require to extend the templates to handle the array returned by the library
and phpwrapper to be installed in campsite.
It sure it's a PRO the fact that we can reuse Smarty plugins and I know there are lots of them, I said that.
Mugur
Micz Flor wrote: At 10:31 12.04.2006, Mugur Rus wrote:
>By using Smarty or Savant we implicitly can benefit from any plugin
>available for one of these template engines. It seems Smarty has a huge
>library of plugins available so that would be an advantage. But as I said
>in my first email having three layers of languages (PHP, Smarty, Campsite)
>allows the web designer to make mistakes easier and makes the error
>detection much harder.
but wouldn't it be an advantage for campsite if using smarty that third
party applications could be integrated much easier - if they used smarty in
the first place?
sure, there would be a third logic involved, the smarty way of doing
things, but ... let me think of an example ... if there is a library that
reads MP3 metatags from files on the server and returns an array for some
smarty template to be displayed - to make this into a plugin would only
require to extend the templates to handle the array returned by the library
and phpwrapper to be installed in campsite.
So any more thoughts on this stuff? Any decision made yet?
On 4/13/06, Mugur Rus wrote:
> Hi Micz,
>
> It sure it's a PRO the fact that we can reuse Smarty plugins and I know
> there are lots of them, I said that.
>
> Mugur
>
>
> Micz Flor wrote:
> At 10:31 12.04.2006, Mugur Rus wrote:
> >By using Smarty or Savant we implicitly can benefit from any plugin
> >available for one of these template engines. It seems Smarty has a huge
> >library of plugins available so that would be an advantage. But as I said
> >in my first email having three layers of languages (PHP, Smarty, Campsite)
> >allows the web designer to make mistakes easier and makes the error
> >detection much harder.
>
> but wouldn't it be an advantage for campsite if using smarty that third
> party applications could be integrated much easier - if they used smarty in
> the first place?
>
> sure, there would be a third logic involved, the smarty way of doing
> things, but ... let me think of an example ... if there is a library that
> reads MP3 metatags from files on the server and returns an array for some
> smarty template to be displayed - to make this into a plugin would only
> require to extend the templates to handle the array returned by the library
> and phpwrapper to be installed in campsite.
>
> so is this CON partly a PRO?
>
> Micz Flor - micz@mi.cz
>
> content and media development http://mi.cz
> --------------------------------------------------------
> http://www.campware.org -- http://www.suemi.de
> http://www.redaktionundalltag.de
> --------------------------------------------------------
>
>
>
>
> ________________________________
> Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
>
>
As I told you I had some personal business to do, my daughter was sick. She's ok now and I'm back to work but I'll be offline again on Friday and Monday as I'll take a short holiday for Easter.
As I understood most opinions were in favor of Smarty so that's what we're going to use. Besides the fact that Savant and other pure PHP 'template engines' are just APIs that don't provide much infrastructure.
Mugur
Paul Baranowski wrote: So any more thoughts on this stuff? Any decision made yet?
On 4/13/06, Mugur Rus wrote:
> Hi Micz,
>
> It sure it's a PRO the fact that we can reuse Smarty plugins and I know
> there are lots of them, I said that.
>
> Mugur
>
>
> Micz Flor wrote:
> At 10:31 12.04.2006, Mugur Rus wrote:
> >By using Smarty or Savant we implicitly can benefit from any plugin
> >available for one of these template engines. It seems Smarty has a huge
> >library of plugins available so that would be an advantage. But as I said
> >in my first email having three layers of languages (PHP, Smarty, Campsite)
> >allows the web designer to make mistakes easier and makes the error
> >detection much harder.
>
> but wouldn't it be an advantage for campsite if using smarty that third
> party applications could be integrated much easier - if they used smarty in
> the first place?
>
> sure, there would be a third logic involved, the smarty way of doing
> things, but ... let me think of an example ... if there is a library that
> reads MP3 metatags from files on the server and returns an array for some
> smarty template to be displayed - to make this into a plugin would only
> require to extend the templates to handle the array returned by the library
> and phpwrapper to be installed in campsite.
>
> so is this CON partly a PRO?
>
> Micz Flor - micz@mi.cz
>
> content and media development http://mi.cz
> --------------------------------------------------------
> http://www.campware.org -- http://www.suemi.de
> http://www.redaktionundalltag.de
> --------------------------------------------------------
>
>
>
>
> ________________________________
> Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
>
>
---------------------------------
How low will we go? Check out Yahoo! Messenger
will this also be the templating engine for the admin interface? i
lost track if this is still on the menu - to make the plugins for 3rd
party modules easier to integrate in the admin menu.
At 15:53 19.04.2006, you wrote:
>Hi Paul,
>
>As I told you I had some personal business to do, my daughter was
>sick. She's ok now and I'm back to work but I'll be offline again on
>Friday and Monday as I'll take a short holiday for Easter.
>
>As I understood most opinions were in favor of Smarty so that's what
>we're going to use. Besides the fact that Savant and other pure PHP
>'template engines' are just APIs that don't provide much infrastructure.
>
>Mugur
>
>Paul Baranowski wrote:
>So any more thoughts on this stuff? Any decision made yet?
>
>On 4/13/06, Mugur Rus wrote:
> > Hi Micz,
> >
> > It sure it's a PRO the fact that we can reuse Smarty plugins and I know
> > there are lots of them, I said that.
> >
> > Mugur
> >
> >
> > Micz Flor wrote:
> > At 10:31 12.04.2006, Mugur Rus wrote:
> > >By using Smarty or Savant we implicitly can benefit from any plugin
> > >available for one of these template engines. It seems Smarty has a huge
> > >library of plugins available so that would be an advantage. But as I said
> > >in my first email having three layers of languages (PHP, Smarty, Campsite)
> > >allows the web designer to make mistakes easier and makes the error
> > >detection much harder.
> >
> > but wouldn't it be an advantage for campsite if using smarty that third
> > party applications could be integrated much easier - if they used smarty in
> > the first place?
> >
> > sure, there would be a third logic involved, the smarty way of doing
> > things, but ... let me think of an example ... if there is a library that
> > reads MP3 metatags from files on the server and returns an array for some
> > smarty template to be displayed - to make this into a plugin would only
> > require to extend the templates to handle the array returned by the library
> > and phpwrapper to be installed in campsite.
> >
> > so is this CON partly a PRO?
> >
> > Micz Flor - micz@mi.cz
> >
> > content and media development http://mi.cz
> > --------------------------------------------------------
> > http://www.campware.org -- http://www.suemi.de
> > http://www.redaktionundalltag.de
> > --------------------------------------------------------
> >
> >
> >
> >
> > ________________________________
> > Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
> >
> >
>
>
>
>How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Micz Flor wrote: will this also be the templating engine for the admin interface? i
lost track if this is still on the menu - to make the plugins for 3rd
party modules easier to integrate in the admin menu.
At 15:53 19.04.2006, you wrote:
>Hi Paul,
>
>As I told you I had some personal business to do, my daughter was
>sick. She's ok now and I'm back to work but I'll be offline again on
>Friday and Monday as I'll take a short holiday for Easter.
>
>As I understood most opinions were in favor of Smarty so that's what
>we're going to use. Besides the fact that Savant and other pure PHP
>'template engines' are just APIs that don't provide much infrastructure.
>
>Mugur
>
>Paul Baranowski
wrote:
>So any more thoughts on this stuff? Any decision made yet?
>
>On 4/13/06, Mugur Rus wrote:
> > Hi Micz,
> >
> > It sure it's a PRO the fact that we can reuse Smarty plugins and I know
> > there are lots of them, I said that.
> >
> > Mugur
> >
> >
> > Micz Flor wrote:
> > At 10:31 12.04.2006, Mugur Rus wrote:
> > >By using Smarty or Savant we implicitly can benefit from any plugin
> > >available for one of these template engines. It seems Smarty has a huge
> > >library of plugins available so that would be an advantage. But as I said
> > >in my first email having three layers of languages (PHP, Smarty, Campsite)
> > >allows the web designer to make mistakes easier and makes the error
> > >detection much harder.
> >
> > but wouldn't it be an advantage for campsite if using smarty that third
> > party applications could be integrated much easier - if they used smarty in
> > the first place?
> >
> > sure, there would be a third logic involved, the smarty way of doing
> > things, but ... let me think of an example ... if there is a library that
> > reads MP3 metatags from files on the server and returns an array for some
> > smarty template to be displayed - to make this into a plugin would only
> > require to extend the templates to handle the array returned by the library
> > and phpwrapper to be installed in campsite.
> >
> > so is this CON partly a PRO?
> >
> > Micz Flor - micz@mi.cz
> >
> > content and media development http://mi.cz
> > --------------------------------------------------------
> > http://www.campware.org -- http://www.suemi.de
> > http://www.redaktionundalltag.de
> > --------------------------------------------------------
> >
> >
> >
> >
> > ________________________________
> > Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
> >
> >
>
>
>
>How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.