Cross-site includes (CSI)
nav_first.pngFirst: thread:131
HTML Block
Edited: 11 Oct 2012 12:06 by: GoVegan
Comments: 0
Tags:
nav_prev.pngPrevious: thread:137
Per-site profile pages
Edited: 06 Dec 2009 02:58 by: Gabrys
Comments: 0
Tags:
Last: thread:112
Image Module
Edited: 12 Nov 2009 12:22 by: pieterh
Comments: 0
Tags:
nav_last.png
Next: thread:145
Keyboard shortcuts
Edited: 13 Nov 2009 10:34 by: Steven Heynderickx
Comments: 0
Tags:
nav_next.png

Steven HeynderickxSteven Heynderickx wrote on 10 Nov 2009 15:44

Originally suggested by pieterhpieterh on 8 Sep 2009.

Today we often copy/paste code between sites. This is inefficient for maintenance. I'd like to make a dynamic include function.

Invoking the include

[[include :sitename:category:page-name{number} argument="value"... /]] 
[[include :sitename:category:page-name/code/{number} argument="value"... /]]

Where sitename is either the name of the site (excluding '.wikidot.com') or a full wikidot subdomain name, or a custom domain.

The {number} selects a content section (similarly as for %%content{n}%%, allowing multiple sections in a page, included independently. The second form selects a code block, again numbered from 1 upwards.

We also use a new form for arguments, using a more standard 'var="value"' syntax. The value can contain quotes escaped as \". Arguments can also be specified within body of the include using the proposed consistent argument format:

[[include :sitename:category:page-name{number}]]
==== argument
value
[[/include]]

Format of included page

The included page can be in one of three formats:

  • simple page (included fully)
  • sectioned page (each section can be included independently)
  • content mixed with code blocks (code blocks can be included independently)

Argument templating

The include page provides a templating mechanism using the same syntax as for _templates and ListPages. However the only symbols that is valid is: %%include{//name//}%% where 'name' is the name of the argument passed by the called.

All arguments can be given default values by using this syntax: %%arg{//name//}?//default//%%. This matches the proposed syntax for default values in ListPages and _templates.

Conditional templating

The include page can do conditional compile-time templating as follows:

[[if //condition//]] ... wiki text [[/if]]

The condition syntax is either of:

  • argument-name — true if the argument value is a non-empty string except "0" or "false" or "no" or "off"
  • argument-name operator value

Where operator is one of '=', '<>', '<', '<=', '>', '>=', 'in', 'ex'. 'in' and 'ex' take a list of values separated by spaces or commas.

Inline operation

The [[include]] tool, when properly formatted (with a closure), does not produce empty paragraphs before and after, so can be used inline with this syntax:

some text \
[[include sitename\category:page /]] \
some more text

References

This design takes into account the following Community documents:


Start a new sub-thread

CSI assets By gerdami 2 Comments 17 Jan 2010 14:45
CSI inside code block By Steven Heynderickx 0 Comments 16 Nov 2009 09:38
:sitename: By Steven Heynderickx 11 Comments 12 Nov 2009 17:58

We discourage direct comments on this thread: to discuss it, please start a sub-thread.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License