Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Reusing PERL across DCTs
mattpr
In TeamSite 5 Templating, how can I reuse a set of common PERL subroutines
Here is my DCT:
<iw_include pt="../../common/perlroutines.inc" mode="ptlocal"/>
<iw_perl><![CDATA[
iwpt_output(simpleRoutine());
]]></iw_perl>
And here is the code I wish to move out to a common file:
<?xml version="1.0" encoding="UTF-8"?>
<iw_pt name="Common PERL routines">
<iw_perl><![CDATA[
sub simpleRoutine {
return "Works!";
}
]]></iw_perl>
</iw_pt>
I receive the error message
Template Preview And Generate Error:
Could not process template: Y:\default\main\branch\.[snipped]..tpl
:\default\main\branch.[snipped]..tpl
Can anybody suggest a solution please?
Find more posts tagged with
Comments
Adam Stoller
If you want to re-use Perl routines - write a Perl Module - put it somwhere within the
@INC
path and then reference it within your PT within an iw_perl section. e.g.:
<iw_pt name="foo"/>
<iw_perl>
use MyCompany::MyPTMod;
# ... use subroutines from MyCompany::MyPTMod from this point on ...
</iw_perl>
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
mattpr
Thank you
gzevin
or just use perl pragma
require
, if one does not want to write a module, but rather just include some code.
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Tim__D
I'm found this post because I need to do something similar but mine is not working.
use Company::Company_template_util;
my $defaultID = Company::Company_template_util::ranString(10);
This is causing the page to error? Any ideas?
Tim__D
Nevermind all I solved it
require Exporter; etc...............