Markaby's Magic-Permeation Branch #
So, Markaby is so magical it hurts, right? Well, you’ll be glad to hear that Markaby is getting a big dose of more magic! It’s our magic-permeation branch (aka xhtml-careful.)
http://code.whytheluckystiff.net/svn/markaby/branches/xhtml-careful/
Markaby has two big problems that really get in the way. The biggest problem is method_missing. Solution forthcoming. The second problem is helper methods in Rails.
link_to "Total is: #{number_to_human_size @file_bytes}", :action => 'more_totals'
In current Markaby, the above won’t work. The link_to
method and the number_to_human_size
are both helpers methods. Markaby, by default, prefers to print out helper methods. So you’ll end up with:
10K <a href="/c/more_totals">Total is: 10K</a>
But we want to print one out and we want to get the other back as a string. (In ERB, you differentiate with <%
and <%=
.) So to get the bytes back as a string:
link_to "Total is: #{@helpers.number_to_human_size @file_bytes}", :action => 'more_totals'
By calling the @helpers
var, you call the method directly and Markaby can’t intercept. However, in the saturated-with-magic branch, we’ve hooked the to_str
for fragments of HTML. This means that we can tell when you’re using a helper like a string. And things get handled right. So, now you can do:
link_to "Total is: #{number_to_human_size @file_bytes}", :action => 'more_totals'
In a couple days, we’ll talk about the solution to our method_missing
problems and you can help decide if the extra voodoo is paying off.
Oh, and this also means that this will work:
div { h1 { "Welcome to #{strong 'RedHanded'}" } }
Thijs
And are we going to get a nice way to html escape too? Please? At one time—I think 0.3—
text
did it, but in 0.4 it does not do that anymore. And this is just ugly:why
why
Which is to say:
chrisfarms
sooperb, look forward to this appearing in my svn up
topfunky
I love Markaby!
However, it seems to output an XML string before the doctype declaration that forces Internet Explorer into quirks mode.
Has anyone else experienced this? Is there a way to turn it off, or is it part of the builder?
Example: My Site, Narmo
why
Thanks, topfunky.
oy vey
that NARMO site, is sending 1+ meg of crappy images on every load. that is just wrong!
tilman
It would be super awesome if you didn’t ignore every single mail I send you, why.
why
Ouch. I deserved that. It’s true that I am totally undisciplined in every way which can be conceived off. (Off to find tilman’s messages…)
Paragon
I love the idea behind markaby, though I’ve yet to actually use it for anything (I hope to use it in the near future). It inspired me to create the Artisan library for swift creation of DSLs. (Not entirely shameless plug!)
murphy
@topfunky: you can also use
Markaby::Builder.set :output_xml_instruction, false
topfunky
Scott Barron started a CSS builder library that is currently in the XML Builder trunk. I’m debating between using that and using the ideas of Markaby to make a CSS generator (Starkaby?).
Scott’s library is a little bit different than Markaby and it would be nice to have a similar syntax instead of switching between the two.
And I’ll use the trac next time for the bugs. Thanks, why!
murphy rubychan de
mmh. I can’t understand how this new
unfortunately, it didn’t solve this:streams
thing is working. looking at the code did not help. please reveal the magic :)still doesn’t work without
@helpers
.how exactly does Markaby decide “when you’re using a helper like a string”?
I found out that
@helpers
in the Rails plugin is nothing more than the ActionView instance rendering the template. so it provides more than helper methods, eg. the methodcontroller
. while very useful, the name “helpers” is misleading in this case. a synonym (@view
?@my
?) might help.Markaby is great. I use it on my website.
Mom
Bravo, Max!
why
Thankyou, murphy! I’d only been testing this branch with Camping. Rails helpers weren’t done right, svn up and give it another swing please.
murphy
nope, still doesn’t work. perhaps it is something very deep; I post the exact code bit.
prints the home_url before the link.
actually, the whole thing doesn’t work here: your div-h1-string example above only prints out empty div and h1 tags in my document. the output seems to depend on where you put it.
maybe it’s a Rails-only problem.
why
Okay, we’re going to try the Fragment as an absolute delegate for the String class it holds. You call any method and the trap is sprung. Hang in there, murph, this may continue to take some revisions.
But update and, please use this instead:
probablyCorey
I love markaby but I can not find it’s home. I have some patches (One which fixes the doctype error in markaby’s output that may fix topfunky’s IE woes) but have no place to share my changes. The rubyforge project page seems to be a dead end. Please tell us where the secret dev site is so we can contribute!
why
The home of.
Tim and I have been pounding out the new branch all weekend. This is so much better than any previous version.
Comments are closed for this entry.