I note with disappointment a stumbling block I came across when trying to port a very simple site from PHP to (e)ruby.

A typical pattern in web design is to take all the common elements of a design and stick them in one place, for easy inclusion on multiple pages. This might be achieved in PHP using the following technique:

<?php /* header stuff */

<h1>the header</h1>

?> function footer() {?>

<h1>the footer</h1>

<?php} register_shutdown_function("footer"); ?>

Important points about the above:

  1. To include the page design on a page, you need only require one file, right at the top.
  2. The HTML for the page design does not need to be massaged to fit into print statements or anything similar: you can quite easily take an existing HTML document and stick the relevant bits of PHP in; a web designer with no coding experience could realistically work with this.

In eruby, however, I haven't figured out how to do this without introducing extra files: the require statement expects a ruby file, and won't accept an eruby file.


Comments