April 18, 2007

Include

Quickly Process another template and add the results to the current page.

Usage [include {args}]
[include:once {args}]

Type control tag

Data Fields n/a
Description

The [include] tag processes another template and adds the results to the current page.  If this happens inside a block tag, the included template is processed for each iteration of the block.

The [include:once] tag works just as with the [include] tag, but a template is included only once for a given page.

Any number of arguments can be provided to the [include] tag.  These are substituted into the specified template before processing begins. Place markers of the form {1}, {2}, {3} in the included template specify where the argument values will be placed; a single argument may be substituted into the template multiple times simply by inserting the appropriate place marker as required.

Arguments containing spaces must be enclosed in quotes, or they will be treated as multiple separate arguments.

Posted by: Pixy Misa at 04:50 PM | Comments (2) | Add Comment
Post contains 148 words, total size 2 kb.

1

Let me get this straight...  Say, I have

[include butan "hello!"]

in a template.  Would my Include.Butan template be like

"<input type="button" value="{1}">"

which would output a button with the text "hello!" on it?  Cool.

Can we do testing on args?  Like [if {1}]value="{1}"[/if]?

Posted by: McGurk at April 19, 2007 03:40 PM (Ri74D)

2
Would my Include.Butan template be like

"<input type="button" value="{1}">"

That's right.  One note - this is not in place in the current system, but will be included in this weekend's update.
Can we do testing on args?  Like [if {1}]value="{1}"[/if]?
Actually, that won't  necessarily work with the plain if, which always assumes that you've fed it a template tag.  if.nz should do what you want, though.

I'm working to extend this to allow using template tags as parameters in other template tags, using $ to denote a variable as opposed to an absolute value.  So you'll be able to do [include $foo], and the template that gets included depends on what the value of foo is at that point.  That should also make it into this weekend's update.

(This isn't just an academic exercise; I needed this functionality to extend some of the user-interface templates.  Naturally, once it's in place I make it available to everyone. )

Posted by: Pixy Misa at April 19, 2007 03:55 PM (PiXy!)

Hide Comments | Add Comment

Comments are disabled. Post is locked.
11kb generated in CPU 0.0083, elapsed 0.038 seconds.
32 queries taking 0.0319 seconds, 54 records returned.
Powered by Minx 1.1.6c-pink.