PsychoSpunk has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying out TT, and I've run into a problem. I have a variable called script which, if present, will cause a javascript section to be added to my HTML output. I've really got two problems, but one is more severe than the other.

In this particular javascript, I have a couple REs that test user data, but when it gets processed

var reg1 = /^\d{4}$/; morphs into var reg1 = /^d{4}/;

I tried backslashing the characters that get removed, but those get removed. This is my first stab at TT, so I may be doing bad things. I do need the script variable to be parsed because I have some possible runtime configurations that change in the javascript. But that also brings up my other problem. When I specify that I want to test $script_var.value, I mean that I want $script_var to be replaced with the real value of the variable and when the javascript is run, it will test user_name.value. Instead, the process engine complains that it doesn't know what to do with $script_var.value. Is there a way for me to signify to the parser that I want $script_var placed there so that it still reads user_name.value once it's processed?

ALL HAIL BRAK!!!

Replies are listed 'Best First'.
Re: Template Toolkit parses out my backslash
by PsychoSpunk (Hermit) on Dec 30, 2000 at 01:21 UTC
    Update: I made a small change in my template that contains the javascript to be parsed from the above SoPW. I decided that, since the location of the the variable I want set at runtime in the script is static within the form that I am checking, I could use elements[n].value in its place.

    Oddly enough, after I made that change (and a snide comment in the CB), I could create as many freakin' \ characters as I wanted. So, now I get a whole new question:

    Why did the change from parsing elements[$script_var].value affect the process engine's parsing of \ character?

    ALL HAIL BRAK!!!