====== Templater Plugin ====== ---- plugin ---- description: Allows DokuWiki pages to be used as templates for insertion into other pages, similar to Wikipedia author : Daniel "Nerun" Rodrigues (previous author: Jonathan Arkell) email : danieldiasr@gmail.com type : syntax lastupdate : 2024-05-19 compatible : Igor, Jack Jackrum, Kaos depends : conflicts : similar : include, pagetemplater, template, wst tags : template, include, variables, !experimental, !discontinued downloadurl: https://github.com/nerun/dokuwiki-plugin-templater/tarball/main bugtracker : https://github.com/nerun/dokuwiki-plugin-templater/issues sourcerepo : https://github.com/nerun/dokuwiki-plugin-templater donationurl: https://www.paypal.com/donate/?hosted_button_id=T95ZWHGTG2GT2 ---- ===== Description ===== **Templater** plugin is a fork of a very old version of [[plugin:include]] plugin. Like the include plugin, it allows you to embed one wikipage inside of another. Unlike the include plugin, the Templater also allows you to pass **substitution strings** to the wikipage to be included, changing the output of the included wikipage (as with MediaWiki's **infobox**). ^ Include from a... ^ Code to insert ^ | ...whole single page | ''%%{{template>pagename}}%%'' | | ...different [[:namespaces|namespace]] | ''%%{{template>namespace:pagename}}%%'' | | ...top namespace | ''%%{{template>:pagename}}%%'' | | ...subnamespace | ''%%{{template>.namespace:pagename}}%%'' | | ...section (including all its subsections) ''[1]'' | ''%%{{template>pagename#sectionname}}%%'' | ''[1]'': When including only a specific section, the //specified heading// will not be printed, only the subheadings will be (lower level). And when the plugin finds a header at the same level as the //specified heading//, it stops printing. ==== Parameters and String Substitutions ==== The real power of Templater comes in to play when you want to use the same general layout for an element inside of a wikipage, but with different pieces of data. You create a new template page, and instead of putting in the actual values, you give each value a name, and enclose them in at-signs like this: My name is @name@. I am a @value@. Including in a wikipage and substituting strings: {{template>pagename|name=Daniel|value=maintainer}} Which outputs this: My name is Daniel. I am a maintainer. :!: **Important notes:** - Users can enclose even **titles and subtitles** in between at-signs (''@'')! In other words: titles and subtitles can also be parameters to be provided in templates. - Users can wrap their strings in **quotation marks** in order to keep any intentional leading or trailing whitespace. Useful for bulleted lists, code blocks etc. If you need the substituted string to end or begin with quotation marks, just use double quotes as in ''%%""my string""%%''. - For now it's impossible to use image tags ''%%{{URL}}%%'' as direct values. You must add a parameter with ''%%{{%%'' and ''%%}}%%'' outside the at-signs, as with ''%%{{@img@}}%%''. ==== Escape Sequences ==== There are just one for now. ^ Character ^ Escape sequence ^ | %%|%% | %%\|%% | | %%=%% | %%automatic, no action needed%% | ===== Installation ===== To install, you can use the URL given above. For more details, read [[:plugin installation instructions]]. ===== Style ===== The included page is set into a ''
'' tag of class ''templater''. .templater { padding: 0.5em; } ===== Recent Changes ===== {{rss>https://github.com/nerun/dokuwiki-plugin-templater/commits/main.atom date}} For a complete [[https://github.com/nerun/dokuwiki-plugin-templater/blob/main/CHANGELOG.md|changelog]]. ===== To Do ===== * Better error handling in ''_massageReplacers'' * Make templated (generated) pages indexable using ''idx_addPage()'' for fulltext search and backlink lookup using ''ft_backlinks()'' * Template caching of parser instructions. * Make the code a little clearer * Use ''>'' in template arguments to point to a wikipage containing a dataset. * Default template namespace. -> //added only config entry, but not implemented// ---- ===== FAQ ===== ==== Is there any way to include MediaWiki's ParserFunctions in a template? ==== About [[https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions|MediaWiki's ParserFunctions]]. Take a look at [[ParserFunctions]] plugin. ==== Is generated content indexable? ==== **No**, but this is in the roadmap. Pages should be indexable by using ''idx_addPage()'', and for for fulltext search and backlink lookup using ''ft_backlinks()''. ==== Is possible to include pictures in the page using a template? ==== **Yes**, but it depends on how you do it. You can not directly include the image tag inside a template: ''%%{{}}%%''. Instead, you sould use a parameter with key brackets around it: ''%%{{@@}}%%'', then provide only the URL as a parameter. ==== Is possible to use template inline? ==== **No**, and i don't know how to implement that. File ''syntax.php'' renders page around lines 220-240. But delete ''
''s changes nothing. Some issue with DokuWiki's ''p_render''. XHTML always render any text in a line as ''

...

'' and it's always breaks line. ==== Compatibility with ODT plugin ==== Pages exported with [[plugin:odt|ODT plugin]] are empty and I don't know how to fix it. ==== Compatibility with other DokuWiki templates ==== This plugin was tested only with DokuWiki default template, other templates was not (and will not be) tested. At least one user reported that this plugin does not work as expected with [[template:dokucms]]. ---- ===== Discussion ===== ^ House cleaning ^ | Outgrown discussions about bugs and new features that have already been fixed or included in past versions will be deleted. \\ Discussions stopped for a long time will be deleted and included in the FAQ. | ---- ==== Data entry and handling suggestions. ==== I very much needed this plugin, thanks. I think the data entry needs to be handled much easier than it currently is. Maybe something similar to the [[plugin:template|template plugin]] datafiles which uses a normal DokuWiki list of name:value pairs and is much easier to write. The template plugin allows the data to be culled from a data page or inline in the arguments. Also the template plugin data files support multiple records in one file, if would be very nice to see a module mode where it can loop the data set through the template for each one or for a specific field match. Oh that would also allow for entry of more markup that cant be normally added in ''{}''. --- ShawnA ---- ==== Footnotes ==== Currently, footnotes are rendered at the end of the template rather than the end of the page. For some use cases this is fine, but for things like infoboxes, it breaks the entire formatting of the page, with only moderate workarounds available. Thanks for adopting this plugin! --- [[turq@mage.city|Turq Whiteside]] > This comportament of footnotes was true for me up to this afternoon, but this night it's working... I don't understand. I have changed rewrite rules as explained in [[:rewrite]], setting to ''.htaccess''. But even getting back to normal (userwrite = 0), it's still working. > --- [[user>nerun|Daniel D. Rodrigues]] //2023-12-06 02:05//