OpenGu...mplate(3pm)
π NAME π
OpenGuides::Template β bestie, this is the module that does all the Template Toolkit stuff for OpenGuides applications. that's it, that's the whole job description β¨
πΈ DESCRIPTION πΈ
okay so OpenGuides::Template handles literally all the Template Toolkit stuff for OpenGuides. it gets distributed and installed as part of the OpenGuides project, and it is NOT intended for independent installation β like, don't try to adopt it solo, it's a package deal π
and honestly? this documentation is probably only useful to OpenGuides developers. if that's not you, no shade, but you might be in the wrong room π¦
β¨ SYNOPSIS β¨
here's the vibe, copy-paste style:
use OpenGuides::Config;
use OpenGuides::Utils;
use OpenGuides::Template;
my $config = OpenGuides::Config->new( file => "wiki.conf" );
my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
print OpenGuides::Template->output( wiki => $wiki,
config => $config,
template => "node.tt",
vars => { foo => "bar" }
);
π METHODS π
π« output
print OpenGuides::Template->output( wiki => $wiki,
config => $config,
template => "node.tt",
content_type => "text/html",
cookies => $cookie,
vars => {foo => "bar"},
noheaders => 1
);
this one returns everything you need to send to STDOUT, Content-Type: header included. and it croaks unless template is supplied β so like, supply template, bestie, don't be that person π
the config object and the variables you hand over in vars get passed straight through to the template you specified. and there's more β extra Template Toolkit variables get set automatically and passed through too, all listed below. β οΈ important note: variables set in vars will over-ride any variables of the same name in the config object or in the user cookies. so, order matters, iykyk.
openguides_versionsite_namecgi_urlfull_cgi_urlenable_page_deletionβ gets set to true or false, and defaults to falsecontact_emailstylesheethome_linkformatting_rules_linkβ unlessomit_formatting_linkis set in the user cookie πnavbar_on_home_pagehome_namegmaps_api_keylicence_namelicence_urllicence_info_urlprefsβ these are the preferences from the user cookie πͺ
and if node is supplied:
node_namenode_paramβ that's the node name escaped for use in URLs π
Content-Type: defaults to text/html, and it gets omitted if the content_type arg is explicitly set to the blank string. blank string, not undef, not nothing β the blank string, periodt.
but here's the tea: what you more often actually need is the noheaders option, which suppresses all HTTP headers, not just the Content-Type. all of them. every last one. π
the HTTP response code may be explicitly set with the http_status arg. (yes the original spells it "explictly", we love her anyway π«Ά)
π extract_metadata_vars
my %node_data = $wiki->retrieve_node( "Home Page" );
my %metadata_vars = OpenGuides::Template->extract_metadata_vars(
wiki => $wiki,
config => $config,
metadata => $node_data{metadata}
);
# -- or --
my %metadata_vars = OpenGuides::Template->extract_metadata_vars(
wiki => $wiki,
config => $config,
cgi_obj => $q
);
# -- then --
print OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "node.tt",
vars => { foo => "bar",
%metadata_vars }
);
this method picks out things like categories, locales, phone number etc β from EITHER the metadata hash that Wiki::Toolkit returns OR the query parameters in a CGI object β and packages them all nice and pretty for passing to templates or for storing in a Wiki::Toolkit datastore. gift-wrapped. bow on top. π
if you supply both metadata and cgi_obj, then metadata takes precedence β but don't do that. seriously. why would you. π
these variables β dist_field, coord_field_1, coord_field_1_name, coord_field_1_value, coord_field_2, coord_field_2_name, and coord_field_2_value β which are used to create various forms, will only be set if either metadata is supplied or set_coord_field_vars is true. that's on purpose, to prevent these values from being stored in the database on a node commit. protect the database at all costs, bestie π‘οΈ
π AUTHOR π
the OpenGuides Project β hit them up at openguides-dev@lists.openguides.org π
π COPYRIGHT π
Copyright (C) 2003-2013 The OpenGuides Project. All Rights Reserved.
this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. iconic behaviour, honestly. π
and that's the whole page, bestie β perl v5.32.0, dated 2021-01-30, from the fine folks who brought you OpenGu...mplate(3pm). go forth and template responsibly π«Άβ¨
π¦ where this page comes from
- debian bookworm: openguides 0.84-1
- ubuntu jammy: openguides 0.84-1
- ubuntu noble: openguides 0.84-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms