tel2 has asked for the wisdom of the Perl Monks concerning the following question:
I’m writing a web application in Perl. It has a form containing contact information, the code for which is currently laid out something like this:
Later on I print $form_htm (amongst other things) to display the webpage.$form_htm = <<EOF <input value="$in{firstname}" name="firstname"> <input value="$in{surname}" name="surname"> ...etc... EOF
The above is working for me, and the fields are interpolated as expected.
However, I’d like different organisations who use this application to be able to have a different layout for their fields. Some fields won’t apply to some organisations, and some organisations will want different sizes (on the webpage) for fields than others.
So, I thought I’d store the HTML for the form in a database (different versions in different records for different organizations).
But because the HTML is not stored in the script, the fields (like $in{firstname}) are not interpolated, so the variable names themselves are ending up on the webpage, (which is not quite the look I’m after).
Any recommendations on how I should get these variables to be evaluated in this context? (First thing that came to mind is eval(), but that seems aimed at evaluating expressions, not variables mixed in with a lot of other text.)
Or can you suggest a better approach which would allow different organisations to have different form layouts?
Edit: I have also posted this question on StackOverflow, but would like to get other opinions.
Thanks.
tel2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interpolation of variables in stored HTML
by NetWallah (Canon) on Nov 03, 2016 at 05:28 UTC | |
|
Re: Interpolation of variables in stored HTML
by kevbot (Vicar) on Nov 03, 2016 at 06:01 UTC | |
|
Re: Interpolation of variables in stored HTML (template)
by Anonymous Monk on Nov 03, 2016 at 04:37 UTC | |
|
Re: Interpolation of variables in stored HTML
by Your Mother (Archbishop) on Nov 03, 2016 at 14:55 UTC | |
by tel2 (Pilgrim) on Nov 04, 2016 at 02:58 UTC | |
by Your Mother (Archbishop) on Nov 04, 2016 at 12:21 UTC | |
by Anonymous Monk on Nov 04, 2016 at 08:51 UTC | |
|
Re: Interpolation of variables in stored HTML
by choroba (Cardinal) on Nov 03, 2016 at 21:58 UTC | |
by tel2 (Pilgrim) on Nov 04, 2016 at 02:53 UTC |