Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Two Template Toolkit questions

by nop (Hermit)
on Feb 23, 2002 at 17:03 UTC ( #147081=perlquestion: print w/replies, xml ) Need Help??
nop has asked for the wisdom of the Perl Monks concerning the following question:

Two small questions on TT2:
  • How do I escape apostrophes? eg I'd like have a proper apostrophe in the word "dont" in this code:
    [% header(title='Dont try this') %]
  • How do I use a TT2 variable in a TT2 function call? eg if  [% c1 %] is a TT2 variable, how do I do something like this?
    [% CGI.textfield(name =>"copy1", size=>50, maxlength=>50, default=>c1) +%]
    The code above breaks the quote.

Replies are listed 'Best First'.
Re: Two Template Toolkit questions
by lachoy (Parson) on Feb 23, 2002 at 19:27 UTC

    Just like Perl, you can use single or double quotes:

    #!/usr/bin/perl use strict; use Template; my $template = Template->new(); $template->process( \*DATA, { runme => sub { return "<$_[0]->{title}>" } } ); __DATA__ [% runme( title = "don't try this" ) %]


    <don't try this>

    M-x auto-bs-mode

Re: Two Template Toolkit questions
by Dog and Pony (Priest) on Feb 23, 2002 at 17:29 UTC
    I admit I haven't used this module, but you have tried 'Don\'t try this'? If you are looking for the HTML escape though, I think it is "&#39;".
    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.
Re: Two Template Toolkit questions
by nop (Hermit) on Feb 23, 2002 at 17:12 UTC
    Well, after scratching my head a bit, I realized the second one is fine. It looked broken (it wasn't) because  c1 was coming from a database field and was right-packed with spaces -- almost 1200 of them.

    Still wondering about my 1st question, tho


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://147081]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2016-09-27 21:30 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (513 votes). Check out past polls.