Scriptor / pharen

Lisp to PHP Compiler
http://pharen.org
BSD 3-Clause "New" or "Revised" License
218 stars 31 forks source link

Basic web site example with Pharen - invitation #56

Closed thinkadoo closed 10 years ago

thinkadoo commented 10 years ago

I made a basic web site with Pharen and really like using it so far.

I hope to get pointers on how one would do it better.

Here it is https://github.com/thinkadoo/lispy

Scriptor commented 10 years ago

Hi Andre, thanks for using pharen! I'll give a few quick bits of advice now and hopefully I'll have the time later to do a more thorough review of the code.

First, my advice for the views would be to just use regular html+php pages for now, rather than printing blocks of html code. Pharen isn't quite suited for mixing with html, at least not for the moment, so doing it the old-fashioned way makes more sense. Using pharen for anything that's not mixed with html (like controllers and routing) should be fine.

There's a macro called load that you may find useful. Instead of doing something like (require "lispy.php") you can do (load lispy). This both inserts a call to include (maybe I should change this so it calls require instead) and compiles the pharen code inside it. This has several advantages including not needing to remember to compile all those files and putting any macros and partials in scope.

You can use the #foo syntax to pass along and return functions. So instead of (map "make_link" urls) it's better to do (map #make-link urls). This also converts dashes and other characters for you so that you don't have to remember as well as prepending the name with the correct namespace.

I noticed that your view functions return (:done). Since :done simply gets compiled to "done", this might lead to problems, though you might also be intending to do something else. If you just need to return :done then you can omit the parentheses.

Feel free to let me know if there's anything in pharen that could be fixed or improved. I'm currently working on redoing the documentation for it, so hopefully those will also be more comprehensive.