Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Embeding Perl in HTML the PHP way

by aaron_baugher (Deacon)
on Sep 11, 2012 at 22:33 UTC ( #993077=note: print w/ replies, xml ) Need Help??


in reply to Embeding Perl in HTML the PHP way

Your example is how it's done in HTML::Mason, although the syntax would be slightly different. For one thing, you don't need the printf at all, since you're just printing a string. So you can do any of these:

<body> <% $some_string %> </body> <body> % print $some_string; </body> <body> <%perl> print $some_string; </%perl>

Like others here, I prefer frameworks these days. Mixing code with layout just doesn't scale well at all. Mason is better than PHP because it's Perl, but things still get ugly easily for some of the same reasons they do in PHP. Currently I'm using Dancer with Dancer::Template::Mason as my templating system, and liking that quite a bit. My templates are Mason, so they can use Perl code for things like loops, rather than requiring me to learn some new templating system's loop syntax. But since all my actual code that processes the data (Controller and Model, in MVC terms) is separate, the template files are still very clean.

Aaron B.
Available for small or large Perl jobs; see my home node.


Comment on Re: Embeding Perl in HTML the PHP way
Download Code
Re^2: Embeding Perl in HTML the PHP way
by sundialsvc4 (Abbot) on Sep 12, 2012 at 00:14 UTC

    Yes, I think that everybody figured out pretty-quickly that the inline-code approach was an inferior approach ... particularly when I18N (internationalization) began to be a very big deal in this world-wide web of ours.   Really good templating systems, and then, really good web frameworks built on them, appeared in most language systems and all of them have matured along generally similar lines.   There is no reason to “go back,” and an abundance of reasons not to.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993077]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2014-09-24 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (244 votes), past polls