develooper Front page | perl.perl6.users | Postings from October 2018

Re: Default directory for files

Thread Previous
From:
Elizabeth Mattijsen
Date:
October 16, 2018 09:35
Subject:
Re: Default directory for files
Message ID:
B8C2485B-C508-4C32-AA35-EEA333D833FF@dijkmat.nl
$?FILE.IO.sibling(‘Templates’) ?

> On 16 Oct 2018, at 10:33, Richard Hainsworth <rnhainsworth@gmail.com> wrote:
> 
> Hi.
> 
> Haven't been able to work this one out from the documentation. There must be a simple answer.
> 
> I am developing a module that renders stuff into HTML.
> 
> The module uses mustache templates for most of the HTML boilerplate. I have default templates, but I want to allow the user to be able to over-ride the templates and supply his/her own.
> 
> Suppose the repo directory structure is
> 
> lib/Module/myModule.pm6
> 
> lib/Module/Templates/main.mustache
> 
> 
> and the main exported function is defined as
> 
> sub render($stuff-to-be-rendered, Str :$template-dir = '?????' ) {
> 
> die 'no templates' unless "$template-dir/main.mustache".IO ~~ :f;
> 
> ...
> 
> }
> 
> What do I put in place of ???? in order for the default to refer to Module/Templates?
> 
> Thanks in advance.
> 
> Richard

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About