Mab: The tiny Markaby-alternative
judofyr at gmail.com
Mon Dec 19 14:26:09 EST 2011
2011/12/19 Bartosz Dziewoński <matma.rex at gmail.com>:
> 2011/12/19 Magnus Holm <judofyr at gmail.com>:
>> That's actually supported. If an attribute is `true` it will use the
>> attribute name as the value. (so checked: true is the same as checked:
>> "checked"). Also, false and nil attributes won't be included.
> I think this is a little inconsistent now. We're already checking
> whther a tag can have content according to an arbitrary list (taken
> from HTML5 standard, I suppose) - we should probably also check
> whether an attribute must have content, or can be boolean (or, to
> check neither - it would be cool if it was possible to disable this
> validation, I sometimes use Markaby for generating XML, or RSS feeds).
> There might exist valid reasons for passing `true`/`false` as
> attribute value and expecting it to show up (possibly for value
> attribute on select list options or radio buttons), as well as passing
> a truthy value that is not `true` itself (for example,
> Numeric#nonzero? returns either `false` or `self`, and one might want
> to have a checkbox checked or not according to it).
> Both of the above problems can be solved by using respectively
> `true_or_false.to_s` or `!!integer.nonzero?`, but both of these
> solutions are kind of ugly.
`!interger.zero?` is another way :-)
> I can change the code myself if you don't feel like it. :)
The real question here is: Should it be a part of camping/mab.rb or
the Mab-gem? I'm definitely for adding many features (indentation,
attribute-validation, flow-validation), but not in Camping. The
Camping implementation should just be enough to get you started.
More information about the Camping-list