Source of template.plp
Back
  1. <(template.plp)>
  2. <: BEGIN { $title = 'Migration' } title 'Migration from version 2 to 3' :>
  3. Some features are no longer necessary in PLP 3. Because backwards compatibility would be too much
  4. of a mess, you need to convert existing scripts.<BR><BR>
  5. <: item 'Begin blocks' :>
  6. The underscore-blocks no longer exist. They are obsoleted by the fact that you can now set headers anywhere, as long as you haven't output anything before. To convert existing scripts, use Perl's BEGIN block feature:<BR>
  7. PLP 2:<BR>
  8. <: code Entity  q{<_ $header{Content_Type} = 'text/plain'; _>}; :>
  9. PLP 3:<BR>
  10. <: code Entity qq{<: BEGIN { \$header{Content_Type} = 'text/plain'; } :\>}:>


  11. <: item 'Formatting blocks' :>
  12. This confusing feature wasn't used by many. It wasn't necessary either, because Perl already has subs for recurring things.<BR>
  13. PLP 2:<BR>
  14. <: code Entity qq{<[1title]><h2><[2]></h2><[3]>\n<[title:Hello, world!]>}; :>
  15. PLP 3:<BR>
  16. <: code Entity qq{<:\n\tsub title { print '<h2>', shift, '</h2>'; }\n\ttitle 'Hello, world!';\n:\>}; :>

  17. <: item 'Inline double quotation' :>
  18. Another feature that lead to a lot of confusion. PLP now uses ASP/PHP style equal-signs. Please not that you can not add a semi-colon and another command.<BR>
  19. PLP 2:<BR>
  20. <: code Entity qq{<{Hello, \$name!}> // Hello, <{\$name}>!}; :>
  21. PLP 3:<BR>
  22. <: code Entity qq{<:="Hello, \$name!":\> // Hello, <:=\$name:\>!}; :>

  23. <: item 'Code inclusion' :>
  24. In PLP 2, it was possible to use &lt;(filename)> in code, and it would
  25. literally include the contents of the file at that place. However, that made
  26. it impossible to easily use regexes like <code>/&lt;&lt;([^>]*)>/</code>. You can
  27. use Perl's built-in do() for pure-perl inclusion, or the new PLP include() function (or
  28. a &lt;(filename)> tag outside of code). If you choose for PLP inclusion, don't forget to add
  29. code tags to the included file!<BR>
  30. PLP 2:<BR>
  31. <: code Entity qq{<: <(filename)> :\>}; :>
  32. PLP 3:<BR>
  33. <: code Entity qq{<(filename)> <: ... :\>\n<: include('filename'); :\>\n<: do('filename'); # perl-only file\n:\>}; :>

  34. <: item 'Comments' :>
  35. In PLP3, you can comment closing :> tags. That means that you need an extra line break if you had :> after #.<BR>
  36. PLP 2:<BR>
  37. <: code Entity qq{<: # foo :\>}; :>
  38. PLP 3:<BR>
  39. <: code Entity qq{<: # foo\n:\>}; :>
  40. <BR><BR><BR>
  41. After all of this, you might like to know that PLP 3 is a lot faster, and supports mod_perl. Happy hacking!