I’m looking to implement a “plug-in” language which is essentially just
HTML plus a few custom tags that I want to support. For example, some
source code in this language might look like
something
something else
where FOO and BAR are special tags that have some meaning that I define.
Say, for this example, that FOO strongs text inside a
tag, and BAR
emphasizes text inside a blink tag. So the “compiled down” source would
look like
something
something else
Is there some open-source software that already does something like
this? Absent that, it seems like the best way is to just read in the
HTML with something like XmlSimple, write a simple interpreter to grovel
over the expression, evaluating the custom tags as they come up, and the
spitting out the resulting HTML.
Is there some open-source software that already does something like
this? Absent that, it seems like the best way is to just read in the
HTML with something like XmlSimple, write a simple interpreter to grovel
over the expression, evaluating the custom tags as they come up, and the
spitting out the resulting HTML.
I’m looking to implement a “plug-in” language which is essentially
just
HTML plus a few custom tags that I want to support. For example, some
source code in this language might look like snip
That sounds an awful lot like XML with XSL stylesheets… I don’t know
much about these, but I would start here http://www.w3schools.com/xsl/xsl_languages.asp
if I wanted to learn.
Template engines also sound like a good fit. There are many for Ruby
(and I know I’ve seen pages that describe their various benefits). You
could start with looking at erb though, which is in the Ruby standard
library: