On Thu, Dec 1, 2011 at 5:30 PM, Brion Vibber <brion(a)pobox.com> wrote:
On Thu, Dec 1, 2011 at 8:17 AM, Ron Laufer
<gonzoron(a)hotmail.com> wrote:
I'm trying to use selective transclusion but via a template and I'm
running into recursion issues.
I would like to create a template that, when transcluded in a page (call
it page A), causes that page to have a section surrounded by the
<onlyinclude></onlyinclude> tags. Then when I transclude page A in page
B, only the surrounded section of page A is shown in page B. The trouble
of course is that if I put those tags in the template, then they get
triggered on the first transclusion into page A. Is there a way to
"escape" those tags such that each transclusion strips off a layer of
escaping characters?
I'm pretty sure you can't do this; <onlyinclude> etc are interpreted at
the
same level of parsing as template invocations; by the time you're expanding
a template you're too deep already.
-- brion
I remember a similar question on Wikimedia Commons. I'm not sure if it's
exactly the same and helps you – the way it was done there was to actually
use it on itself.
Something like
<onlyi<includeonly/>nclude>foo</onlyinc<includeonly/>lude>.
(yeah I know, pretty, isn't it, brion?)
Depending on how it's used it may only work in a "subst:" context, if
that's the case and you need it without subst, perhaps try something with a
subtemplate using "safesubst:"
- Krinkle