hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

Markaby 0.3 #

by why in inspect

Now that Markaby’s had some life experiences, Tim and I have sucker-punched it a bit here and there. And the sum of those shapings is 0.3.

You already know to gem install markaby.

  • Finally, full documentation.
  • A new render_markaby method for quickly outputting from inside a controller.
  • Cleaned up for general Ruby use, just attach a block to Markaby::Builder.new containing all your HTML calls.

A tip: you know how all calls to helpers are automatically output to the builder stream? Well, if you need the helper method’s output, just call it against the @helpers instance var.

 p "Total is: #{@helpers.number_to_human_size @file_bytes}" 

At least until we decide upon something fancier.

said on

great stuff !

said on

I guess it’s a personal style thing, but isn’t using {}’s rather than do/end better in terms of representing the hierarchical nature of XML ? e.g.

html { body { } }

rather than :

html do body do end end

(I did have them spaced over several lines, but it gets messed with by the rouge cloth)

said on

Superb.

said on

Thank you for the docu!

said on

What’s the easiest way to work on a page’s markup using Markaby (y’know, without anything else)?

Binding a folder with Markaby template files to Webrick (or Mongrel) and then editing and refreshing from there?

said on

jakdak: yeah, a lot of people seem to prefer using braces in this context. looks neater.

said on

Danno – thats a fair point. Maybe we need an .xhtml → .mab converter :p :o)

said on

Don’t you mean .mab → .xhtml?

Hrmm… then I could tell vi to invoke that whenever I saved a .mab file and just look back and forth at the changes.

said on

HTML preview?

TextMate users can add a command…

Save: Nothing
Command(s): ruby -rrubygems -e "require 'markaby'; puts Markaby::Builder.new { eval(STDIN.read) }"
Input: Entire Document
Output: Show as HTML
Scope Selector: source.ruby

said on

Yeah, that’s what I’m talking about.

Now I, just have to figure out how to do it in vim.

said on

thats very cool stuff

an .xhtml → .mab would be useful too :)

said on

How do you add attributes to tags other than id and class?

said on

JM: you can pass a hash after the text:

p.important "Bla.", :lang=>"de"
said on

Nice, very, very nice

said on

dvoodoo: Thank you sir!

said on

It would be cool if you could change the charset used by head in its meta tag. builder.rb can check @helpers.headers[‘Content-Type’], but that only works if the header was explicitly set (with before_filter, for instance). I’m not sure how to get at the final Content-Type header Rails decides on, or even where Rails decides what that is.

said on

I started building a page in Markaby (it’s taking me a while since I’m horrible at CSS ) and one thing I noticed that’d be nice is if Markaby had some kind of placeholder for the Rails helpers, I don’t know if that’s possible… or maybe I should just stick the dang file into a view and test through script/server…

said on

Changes to the value of instance variables inside a Markaby template should be transported to the layout, like it happens with regular .rhtml templates.

said on

Hmm. I’m wondering about the nicest way to html-escape stuff like the decription in self << category.description ?

said on

Hmm again. Is there a way to set the class dynamically that’s nicer than doing eval "span.status.#{story.status} story.status" ?

said on

Thijs: Fall back to:

 span story.status, :class => "status #{story.status}" 

To html escape stuff use the text method:

 div do
   text category.description
 end

Which is identical to:

 div category.description
said on

J’ai un petite Question:

I have a method called “logged_in?” defined in mon ApplicationHelper.

When I use that method from inside un .mab file, I get cette petite error:

builder.rb:161:in `instance_variable_get': `@logged_in?' is not allowed as an instance variable name

Vous avez any ideas what that is?

Looks very alien to moi

said on

Dopey: that’s a bug! Should work ok now (as of rev 28)

said on

Merci beaucoup monsieur

(I’m not actually french. I just . umm .. yeah you can see by my screename)

said on
A few newbie questions: <td> <%= name %> <% if condition %> <%= extrainfo %> <% end %> </td> To convert this to markaby, it seems the way is: td { a = name if condition a += extrainformation end a }

I was wondering if having the temporary variable is how it’s supposed to be done.

Second. How do I get <br/> into a string? For example:
th "A" + br + "B" seems to break.
said on

Maybe the first could be:

 td "#{name}#{extrainformation if condition}" 

A lot of times I’ll use RedCloth for formatting with breaks in it, italics, bold and the like.

said on

I think you should consider adding an option to enable/disable the XML instruction that is inserted before the doctype – adding this will throw IE into quirks mode which is often what you don’t want.

said on

trying to figure out how to use this neat blob of code. so far ive added:

require ‘markaby’ ActionView::Base::register_template_handler :mab, Markaby::Template

to my app (id love to try the plugin but the code server seems down and additionally goggles seems to not want to show the cache)

`@html do’ is not allowed as an instance variable name /usr/lib64/ruby/gems/1.8/gems/markaby-0.3/lib/markaby/builder.rb:55:in `instance_variable_set’

said on

went on a spelunking mission and found out i was delegating to the wrong class. of course now the SVN server has returned where all this is bleedingly obvious. next quest: write a regex, or manually convert? /me flips a coin…

said on

Hi there, it would seem that as of rails edge version 3989 the plugin does not work, it just displays the source of the template rather than rendering it. Not sure why this is. It definitely seems to be version 3988 which is the last to work. I’ve tried previous and subsequent versions, subsequent ones don’t work, previous ones do.

Thanks

said on

so attempting to get the instance variables that are created inside a .mab (as opposed to a rails controller) to exist in markaby partials this peculiar error message:

[””, ”\n”]

[””, ”\n”, “[\”\”, \”\\n\”] \n \n”, ””, ”\n”]

[””, ”\n”, “[\”\”, \”\\n\”] \n \n”, ””, ”\n”, “[\”\”, \”\\n\”, \”[\\\”\\\”, \\\”\\\\n\\\”] \\n \\n\”, \”\”, \”\\n\”] \n \n”, ””, ”\n”]

i think it says ‘i love you’, in escape-squeak..

Comments are closed for this entry.