using the :escaped filter in #HAML
a useful tip for printing unrendered code to a web page
no comments no links ["I was writing a little markdown key the other day for the comments section that you'll see at the bottom of this page (assuming that you're a do{block} user and that you're logged in to the site, and hit a bit of a snag when I was trying to demonstrate that you can place \"code\" tags around code to make it appear as such.
\n\nProblem is, #HAML seems to interpret code tags automatically for you, regardless of whether they're included in a string or just typed directly into a template. As you might imagine, I spent a bit of time fussing with various escape characters and conventions, to no avail, until it occurred to me that I might find an answer in #HAML's reference guide (which, by the way, is great and wonderful and a read as riveting as any three Mike Nichols films).
\n\nAnyway, it's simple.
\n", nil, "#!/app/views/articles/show.haml\n\n:escaped\n <codetag> @this = is :ruby_code </codetag>
Please note that if you're actually demonstrating code in a comment your tags should read \"code\" rather than \"codetag\". I did this only because, I ironically, I haven't developed a mechanism to escape the plain \"code\" tags from tm_syntax_highlighting.
\n\nAnyway, there you go. Anything that you put under that escape filter will be entirely escaped and won't be rendered in any capacity. I hope it'll save you the hour that it cost me.
\n"]