Project

txprails

0.0
No commit activity in last 3 years
No release in over 3 years
TXPRails is a template engine based on TextPattern for Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

TXPRrails¶ ↑

DISCLAIMER

TXPRails was born kind of an experiment. Please be aware that this is a work in progress.

TXPRails = Textpattern Rails¶ ↑

This gem is an experiment for using Textpattern like templates in a Rails environment. Rails have many template engines available, from ERB thru Haml, etc. However, for many of us from a more traditional PHP/like environment, XML-style templates seems more natural. Moreover, TXP style templates differ from Haml or ERB in one thing: the templates are not “compiled” in the sense of making 1 pre-compile pass (Haml) or more-or-less-directly ruby-executed (ERB). TXP templates are executed while parsing, using different techniques explained below.

I think Haml is kind of awesome, and I’m slowly getting used to it. However, I’m still fascinated of the elegance and simplicity of TXP XML’ish templates. Liquid template fans will also find TXP templates very easy to use.

So, in essence, I started this project solely for this pourposes:

  • Try to make my first publicy available Ruby Gem.

  • Test and experience the C/C++ binding of Ruby. (TXPRails is more or less 80% written in C++).

  • Learn and practice myself some advanced Rails techniques.

  • Just for fun… :-)

*This project and some of the code (namely the Rails plugin bootstrap) is heavily inspired by Haml itself*. Also, there is also some influence of the fluid template engine.

Please, PLEASE, if you find this gem useful, comment and make suggestions to make it better. I think you may also benefit and learn from TXPRails.

EXAMPLES¶ ↑

TextPattern syntax templates have an extension of .txp, you can rename all your templates to use +.txp* extension and will use TXPRails as template engine.

Please, read the manual for Textpattern tags to get the basics.

Textpattern tags are XML. There are two kind of tags: Self referenced and container tags. Self referenced tags are XML self-closed tags like +<txp:content />+. Container tags, on the other hand, have a block of text between the the tag pair like: +<txp:link to=“destination”> …blah, blah…</txp:link>+.

Pay close attention to self-closed tags. They have a forward slash at the end, exactly like XHTML tags.

Textpattern tags have a “domain” and “name” part, like this: +<domain:name />+. The Domain part plays an important role in TXPRails, unlike in Textpattern where they are simply “sintactic sugar”.

Differences from Textpattern¶ ↑

Template Tags in the Textpattern publishing system are very tight coupled. For example, tags like +<txp:permlink />+ requires to have a blog, a post and this post have a permalink. This is not the case with TXPRails, in which we obviously haven’t a blog. In Rails we have Models:

<mod:clients limit="5">
  The name: <var:name /><br />
  The phone: <var:phone /><br />
  <txp:link>View more</txp:link>
</mod:clients>

Note on Patches/Pull Requests¶ ↑

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyleft © 2010 Jose Miguel Perez. Do not see LICENSE for no details.