Re: [Templates] Evaluate a TT variable that contain a TT string
At 8:13 PM on 27 Nov 2009, Octavian Râsnita wrote: From: C. Chad Wallace cwall...@lodgingcompany.com At 8:45 AM on 26 Nov 2009, Randal L. Schwartz wrote: Octavian == Octavian Râsnita orasn...@gmail.com writes: Octavian but if I put just simple html code in the database ... then your successor will submit your code to thedailywtf.com ... and we'll all have a good laugh at your expense. Seriously, wrong way to do it. I agree with Randal, wholeheartedly. You need to maintain a separation between data (in the database) and HTML (in your templates). They should not be mixed. What happens when, for instance, you change your templates to XML rather than HTML? Or you want to present the same data as a PDF? It's going to have HTML in it! Well, as I said, I also agree, but I couldn't find that recommended way. Can you tell me the solution for storing complex documents that include text, lists, tables, headings which doesn't use HTML? I use BBCode for that. There is a Template plugin for BBCode, and there are Perl modules (e.g., Parse::BBCode) that convert from BBCode to other formats. However, Markdown or Textile might work, too... They let you write your formatting in plain text, and then translate it up to HTML or whatever you want. But I think the most presentation-agnostic way to do this would be to define the types of documents your users will want to enter, and then have them select a type, and provide different fields (dropdowns, text boxes, etc.) in your UI based on that type. For instance, you could have a 'section' type, with a 'heading' and a 'paragraph' field, or a 'list' type with a 'heading' and multiple 'items'. Then you store just those fields in the database, and when it comes time to present them, you slot the data into the appropriate HTML tags. The latter may be overkill... that's up to you to decide. But I think HTML is the worst choice here, because your users may end up entering some very complex HTML that would be hard to parse out if needed. Also, giving the user HTML often means they can break the rendering of YOUR HTML if the stuff they've entered is broken! I saw that happen *many* times before switching to BBCode... it's embarrassing to say the least! PS, Let's please keep this on-list, for the benefit of everyone. -- C. Chad Wallace, B.Sc. The Lodging Company http://www.skihills.com/ OpenPGP Public Key ID: 0x262208A0 signature.asc Description: PGP signature ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
From: C. Chad Wallace cwall...@lodgingcompany.com At 8:13 PM on 27 Nov 2009, Octavian Râsnita wrote: From: C. Chad Wallace cwall...@lodgingcompany.com At 8:45 AM on 26 Nov 2009, Randal L. Schwartz wrote: Octavian == Octavian Râsnita orasn...@gmail.com writes: Octavian but if I put just simple html code in the database ... then your successor will submit your code to thedailywtf.com ... and we'll all have a good laugh at your expense. Seriously, wrong way to do it. I agree with Randal, wholeheartedly. You need to maintain a separation between data (in the database) and HTML (in your templates). They should not be mixed. What happens when, for instance, you change your templates to XML rather than HTML? Or you want to present the same data as a PDF? It's going to have HTML in it! Well, as I said, I also agree, but I couldn't find that recommended way. Can you tell me the solution for storing complex documents that include text, lists, tables, headings which doesn't use HTML? I use BBCode for that. There is a Template plugin for BBCode, and there are Perl modules (e.g., Parse::BBCode) that convert from BBCode to other formats. However, Markdown or Textile might work, too... They let you write your formatting in plain text, and then translate it up to HTML or whatever you want. Ok, thank you. I will compare BBCode, Markdown and Textile and see which of them would be the best for what I need. PS. Sorry for not responding to the list in my previous message. If I wrote you privately only, I've done it by mistake. Octavian ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
Octavian == Octavian Râsnita orasn...@gmail.com writes: Well, as I said, I also agree, but I couldn't find that recommended way. Can you tell me the solution for storing complex documents that include text, lists, tables, headings which doesn't use HTML? If you mean to store documents that must be delivered opaquely as a giant unchanged blob, then yes, that's data. But if there's any templating structure in them, you are violating model vs view, and that will bite you big time later. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
On Thu, Nov 26, 2009 at 12:57:18PM +0100, Harald Joerg wrote: Is it possible to interpret somehow page_body variable to be processed like a template? why just not PROCESS data file ? do you plane to generate templates on fly ? that means you can't cache and i imagine you can have serious performance issues. isn't it possible to write functions (BLOCK) and WRAPPERs ? regards -- Marc Chantreux BibLibre, expert en logiciels libres pour l'info-doc http://biblibre.com ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
From: Harald Joerg harald.jo...@ts.fujitsu.com Octavian Râşniţă orasn...@gmail.com writes: I have a template in which I need to evaluate a variable which is taken from the database like: ... div[% page_body %]/div ... But page_body is a TT template containing a string like: pa href=[% c.uri_for('/path/to/file') %][% c.localize('Label for this link') %]/a/p ... Is it possible to interpret somehow page_body variable to be processed like a template? You are looking for TTs eval filter: http://www.tt2.org/docs/manual/Filters.html#section_eval_evaltt div[% page_body | eval %]/div -- Cheers, haj Oh thanks! I was searching on CPAN after Template and Eval but I couldn't find anything there. Octavian ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
From: Marc Chantreux marc.chantr...@biblibre.com On Thu, Nov 26, 2009 at 12:57:18PM +0100, Harald Joerg wrote: Is it possible to interpret somehow page_body variable to be processed like a template? why just not PROCESS data file ? do you plane to generate templates on fly ? that means you can't cache and i imagine you can have serious performance issues. isn't it possible to write functions (BLOCK) and WRAPPERs ? No I don't generate templates dynamicly, but if I put just simple html code in the database I would also need to hard-code the links, and in that case they will be harder to modify in case I would need to modify the application. For example now the web app runs on the root url (/) but in the future I might need to put it run on a sub-virtual-directory like /something/. If I define the urls using [% c.uri_for('/test') %] this URL will become http://www.mysite.ro/test but in the future if I would put the app to run on /something/, it will automaticly become http://www.mysite.ro/something/test without changing anything. And the truth is that I am not thinking only to the future. I also rewrite the URL so the language of the current page becomes the first part of the URL like: http://www.mysite.ro/en/test I would need to put the same urls in the pages for all the languages and they would get their language automaticly. But thank you for reminding about the performance. I will make some tests and if the performance degrades, I will make the effort of storing only static content. Octavian ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
On Thu, Nov 26, 2009 at 04:01:16PM +0200, Octavian Râsnita wrote: No I don't generate templates dynamicly, but if I put just simple html code in the database You store things it database, that's why! i got it now and it makes sense. regards -- Marc Chantreux BibLibre, expert en logiciels libres pour l'info-doc http://biblibre.com ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
Octavian == Octavian Râsnita orasn...@gmail.com writes: Octavian but if I put just simple html code in the database ... then your successor will submit your code to thedailywtf.com ... and we'll all have a good laugh at your expense. Seriously, wrong way to do it. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
From: Randal L. Schwartz mer...@stonehenge.com Octavian == Octavian Râsnita orasn...@gmail.com writes: Octavian but if I put just simple html code in the database ... then your successor will submit your code to thedailywtf.com ... and we'll all have a good laugh at your expense. Seriously, wrong way to do it. What's wrong? To store html in the database or to use TT markers in that html code? (And it will help me if you'll also tell me why and how can I do it in the recommended way.) Thanks. Octavian ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
Octavian == Octavian Râsnita orasn...@gmail.com writes: Octavian What's wrong? To store html in the database or to use TT markers in Octavian that html code? (And it will help me if you'll also tell me why and Octavian how can I do it in the recommended way.) To store HTML in the database. That's violating the MVC triad, and you'd better have a *really* good reason to do that. HTML is a view. Databases are for models. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
From: Randal L. Schwartz mer...@stonehenge.com Octavian == Octavian Râsnita orasn...@gmail.com writes: Octavian What's wrong? To store html in the database or to use TT markers in Octavian that html code? (And it will help me if you'll also tell me why and Octavian how can I do it in the recommended way.) To store HTML in the database. That's violating the MVC triad, and you'd better have a *really* good reason to do that. HTML is a view. Databases are for models. I agree with this, and I also don't like it, but I couldn't find a better way. I need to offer a way of creating/modifying the pages that present the company, the services by web forms, and those pages contain many paragraphs of text, links, headings, lists and tables. I was also thinking that I could use a wiki-like kind of format, but all the wiki formats I could find are either very unflexible or very hard to create. For example, the twiki style of creating tables is very clear and simple, but very unflexible, while the Mediawiki style of defining tables is more flexible, but very hard to do. (I am blind and the WYSIWYG editors are not an option because they are not accessible for the screen readers.) So that's why I found the HTML format the most flexible and not very hard to create. Please tell me if there is a better way for doing this. Thanks. Octavian ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
On Thu, Nov 26, 2009 at 2:07 PM, Octavian Râsnita orasn...@gmail.comwrote: HTML is a view. Databases are for models. I agree with this, and I also don't like it, but I couldn't find a better way. I need to offer a way of creating/modifying the pages that present the company, the services by web forms, and those pages contain many paragraphs of text, links, headings, lists and tables. Templates are fine in the database. I think you want to PROCESS the template instead of eval, though. I was also thinking that I could use a wiki-like kind of format, but all the wiki formats I could find are either very unflexible or very hard to create. For example, the twiki style of creating tables is very clear and simple, but very unflexible, while the Mediawiki style of defining tables is more flexible, but very hard to do. (I am blind and the WYSIWYG editors are not an option because they are not accessible for the screen readers.) So that's why I found the HTML format the most flexible and not very hard to create. Please tell me if there is a better way for doing this. Thanks. Octavian ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates -- Bill Moseley mose...@hank.org ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates
Re: [Templates] Evaluate a TT variable that contain a TT string
From: Bill Moseley mose...@hank.org On Thu, Nov 26, 2009 at 2:07 PM, Octavian Râsnita orasn...@gmail.comwrote: HTML is a view. Databases are for models. I agree with this, and I also don't like it, but I couldn't find a better way. I need to offer a way of creating/modifying the pages that present the company, the services by web forms, and those pages contain many paragraphs of text, links, headings, lists and tables. Templates are fine in the database. I think you want to PROCESS the template instead of eval, though. I use static templates, that also use a wrapper and in those templates I include things that should appear in (almost) all the pages, like a main heading, a [% PROCESS ... %] line that include another template when some conditions are met, and... the line that include the main body from the database. I have also set the page title, meta keywords and description before specifying the WRAPPER so they appear in the page html header using: [% title = page.title; description = page.description; keywords = page.keywords; WRAPPER wrapper.tt -%] (I don't define these variables in the same TT block after the WRAPPER because for some pages I need to translate them and I use a TT MACRO for doing this and it is not valid a code like: [% WRAPPER wrapper.tt title = l(page.title) %] So in these conditions, I don't know how I could PROCESS that part of the web page which is taken from the database. Anyway, it is pretty confusing because I still don't know which would be the best way of storing complex data that also include text, tables, links, lists, because it seems that storing them as html is not a good idea. I have just read a little about Text::Textile and I think it could be a useful format, however I am not sure for the moment. Octavian ___ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates