S
Sean O'Halpin
b = BindingMaker.new
class << b; include Tagz.globally; end
FYI, you could do this instead:
b.extend(Tagz.globally)
Regards,
Sean
b = BindingMaker.new
class << b; include Tagz.globally; end
It might be neat to add some more dynamic method magic for this, like:
foo_in_bar_ { =85 }
I realize that's a bad example in case you really have a tag with =20
that name, but you get the idea.
Set the $KCODE and use a unicode character as the separator for =20
namespaces ...
$KCODE =3D 'u'
foo=A6bar_('bar:foo' =3D> 42) #=3D> "<foo:bar bar:foo=3D\"42\">"
On Mar 25, 2009, at 9:21 AM, James Gray wrote:
=20
=20
=20
=20
i actually did that with xx at one point.
=20
i think that, or some proxy object is the way to go.
Thanks.
If you had to register the namespaces first in some kind of tagz
registry, maybe you could do something by handling the NameError when
you did:
foo.bar_('bar:foo' => 42)
If it had registered a namespace prefix of foo, then it'd just "do the
right thing", otherwise, you'd get the normal name error. This would
probably be the most logical syntax, but it's way beyond my Ruby
magical
abilities to figure out how to actually make it work.
Still, I think it'd be the most readable of the proposed approaches...
I don't want to have to find unicode characters on my keyboard!
Cheers,
how about this
cfp:~ > cat a.rb
require 'rubygems'
require 'tagz'
class Namespace
def initialize(nsuri) &block @nsuri = nsuri
@ns = block.call.to_s
@context = block
@self = eval 'self', block
end
instance_methods.each{|m| undef_method if m[%r/__/]}
def method_missing m, *a, &b
if m.to_s[%r/^_|_$/]
@self.send("#{ @ns }:#{ m }", *a, &b)
else
"#{ @ns }:#{ m }"
end
end
end
include Tagz.globally
a = Namespace.new(".."){ :a }
b = Namespace.new(".."){ :b }
xml =
a.root_(emit_nsuri => true, include_children => true) {
a.foo_(b.bar => 'bar'){ 'content' }
b.bar_(a.foo => 'foo'){ 'content' }
}
puts xml
cfp:~ > ruby a.rb
<a:root xmlns:a="..." xmlns:b="..."><a:foo b:bar="bar">content</a:foo><b:bar a:foo="foo">content</
b:bar></a:root>
how about this
Apologies. Forgot to say thanks for your help. Your suggestion is
probably good enough for what I need to do, and I can try to manage
the
namespace declarations manually somehow, or actually implement part of
what I suggested.
Looking forward to getting started with tagz!
Cheers,
ast
I have been using haml out of necessity recently (sinatra), erb is
too much like hard work.
I find that haml is deeply frustrating as getting the whitespace
right to nest things properly is, quite frankly, a pain.
Markaby used the right sort of syntax I think and therefore I am
mightily intrigued by Tagz.
Is it fast??
I have been using haml out of necessity recently (sinatra), erb is
too much like hard work.
I find that haml is deeply frustrating as getting the whitespace
right to nest things properly is, quite frankly, a pain.
Markaby used the right sort of syntax I think and therefore I am
mightily intrigued by Tagz.
Is it fast??
On Mar 26, 2009, at 5:43 AM, Andrew S. Townley wrote:
if that's the case i might roll something like that into tagz.
i'll post any other ideas i have here - really appreciate the feedback!
I also discovered that output of empty elements doesn't behave as I'd
expect. If you do
empty_element_
you get "<empty_element>"
rather than "<empty_element/>"
this by design.
it's a false assumption that one never needs to separate opening and
ending tags wrt to scopes
It wasn't an assumption I was making. The assumption I *was* making
was
that the library was biased to ensuring you had well-formed & correct
mark-up. To me, I'd see the need to separate scopes to be something
I'd
want to explicitly request rather than the other way around.
there is actually one other important usecase br_ etc, and other
html4 tags. just fyi.
Who uses HTML4 anymore????
Who uses HTML4 anymore????
Actually, there are enough reasons for sticking with HTML. Especially
interesting is the point how most Browsers consume XHTML, to be found
in [1], section "HTML-compatible XHTML".
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.