Re: [Templates] How to get around max. variable length?

[prev] [thread] [next] [Date index for 2004/11/16]

From: Jason Peck
Subject: Re: [Templates] How to get around max. variable length?
Date: 16:40 on 16 Nov 2004
In case anyone is interested, here is what I figured out in the end to
get around the max. variable length issue:

lib/std.ttl : Standard template for every webpage
[% FOREACH content = content_items %] 
[% content.title %]
[% INCLUDE $content.html_block %]
[% END %]

src/index.tt : A web page
[% INCLUDE std.ttl
  content_items = [
    {
      title => "Welcome",
      html_block => "welcome_block" 
    }
  ]
%]

[% BLOCK welcome_block %]
   Welcome content here with no apparent limit on length.
[% END %]

I guess this is actually better because no I can also put template
directives inside my "welcome_block" where I couldn't before in the
variable only.



On Mon, 2004-11-15 at 23:31, Jason Peck wrote:
> Today, I also tried creating a named block in my template index.tt and
> then tried to pass it's name in the "html" variable below and then
> IMPORT that block in the std.ttl to no avail. 
> 
> You can recreate my problem by using the example below and putting 25K
> text in the html variable. I would be happy also to try some completely
> different overall approach, but I can't come up with anything else that
> fully separates content from presentation as the below does. Of course,
> I could have the "html" variable point to yet another file and then use
> the INCLUDE directive in my std.ttl file to suck it in, but then I need
> two files for every webpage :( .
> 
> If anyone has any suggestions on this I would be most grateful.
> 
> 
> On Mon, 2004-11-15 at 11:34, Jason Peck wrote:
> > Hello,
> > 
> > I hope someone can help me here. I put together a website using template
> > toolkit with the following simple structure. The aim of this structure
> > is to separate content from presentation (the web pages contain no
> > presentation, just content):
> > 
> > lib/std.ttl : Standard template for every webpage
> > [% FOREACH content = content_items %]
> >  [% content.title %]
> >  [% content.html %]
> > [% END %]
> > 
> > 
> > src/index.tt : A web page
> > [% INCLUDE std.ttl
> >   content_items = [
> >         {
> >           title => "Welcome",
> >           html =>   "
> >            Welcome to this webpage.
> >           "
> >         }
> >   ]
> > %]
> > 
> > 
> > However, it seems that template-toolkit seg faults if the any of the
> > variables in my index.tt file (like the html varaible) contain large
> > amounts of text (~25K in my case). Does anyone know a way around this
> > problem? Perhaps there is even a better way to structure this to avoid
> > the problem all together (i.e. not using variables somehow)? 
> > 
> > So far, I have tried setting INTERPOLATE 0 in the index.tt and also
> > tried using ' instead of " around my variables to no avail. 
> > 
> > If anyone could help I would be most grateful!
        -- 
        Jason Peck

Focus Robotics
Tel. 603.594.3097
http://www.focusrobotics.com


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

Re: [Templates] How to get around max. variable length?
Jason Peck 16:40 on 16 Nov 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52