Hi all, I love the elegance of Markaby for HTML generation. I''d like to do something similar for SVG, e.g.: svg11 do title "Slide Title" rect({:x=>2,:y=>2,:width=>508,:height=>318,:fill=>"aqua"}) g({:style=>"fill:blue; stroke:black", :transform=>"translate(17,-38)"}) do circle({:cx=>70, :cy=>100, :r=>50}) rect (:x =>"150", :y=>"50", :rx=>"20", :ry=>"20", :width=>"135", :height=>"100") line(:x1=>325, :y1=>150, :x2=>375, :y2=>50) polyline(:points=>"50, 250 75, 350 100, 250 125, 350 150, 250 175, 350") polygon(:points=>"250, 250, 297, 284, 279, 340, 220, 340, 202, 284") ellipse({:cx=>400, :cy=>300, :rx=>72, :ry=>50}) end end I''ve hacked a custom subclass of Builder (SVGBuilder) that can handle this, but that''s probably the wrong approach -- since most users will want to embed SVG inside HTML. Any Markaby experts here who can help me figure out the best way to integrate SVG support into Markaby? Thanks, -- Dr. Ernie http://ihack.us/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070711/cb08ecb5/attachment.html
Hello. I''m interested in this as well. Timur On 11.07.2007, at 23:26, Ernest Prabhakar wrote:> Hi all, > > I love the elegance of Markaby for HTML generation. I''d like to do > something similar for SVG, e.g.: > > svg11 do > title "Slide Title" > rect({:x=>2,:y=>2,:width=>508,:height=>318,:fill=>"aqua"}) > g({:style=>"fill:blue; stroke:black", :transform=>"translate > (17,-38)"}) do > circle({:cx=>70, :cy=>100, :r=>50}) > rect > (:x=>"150", :y=>"50", :rx=>"20", :ry=>"20", :width=>"135", :height=>"1 > 00") > line(:x1=>325, :y1=>150, :x2=>375, :y2=>50) > polyline(:points=>"50, 250 75, 350 100, 250 125, 350 150, 250 175, > 350") > polygon(:points=>"250, 250, 297, 284, 279, 340, 220, 340, 202, 284") > ellipse({:cx=>400, :cy=>300, :rx=>72, :ry=>50}) > end > end > > I''ve hacked a custom subclass of Builder (SVGBuilder) that can > handle this, but that''s probably the wrong approach -- since most > users will want to embed SVG inside HTML. > > Any Markaby experts here who can help me figure out the best way to > integrate SVG support into Markaby? > > Thanks, > -- Dr. Ernie > http://ihack.us/ > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list
> I''ve hacked a custom subclass of Builder (SVGBuilder) that can handle this, > but that''s probably the wrong approach -- since most users will want to > embed SVG inside HTML. > > Any Markaby experts here who can help me figure out the best way to > integrate SVG support into Markaby?My opinion would be to keep it seperate so that in can be used elsewhere, but provide a hook into Markaby. So something along the lines of this (completely untested): module Markaby class Builder def svg(options = {}, &block) concat SVGBuilder.new(&block) end end end The developer could either have to explicitly require the hook, or, if you make the assumption that Markaby is loaded before the SVG code then you can just test for it''s presence i.e. if defined?(Markaby) and load it based on that. Hope that makes sense - getting late here :)
On 7/11/07, Tim Fletcher <twoggle at gmail.com> wrote:> > Any Markaby experts here who can help me figure out the best way to > > integrate SVG support into Markaby?I worked on a project started by Scott Barron to do something similar for CSS. I''m using SASS now, but here it is for reference: http://topfunky.net/svn/plugins/styleaby/ -- Geoffrey Grosenbach boss at topfunky.com ........................ Blog | http://nubyonrails.com Podcast | http://podcast.rubyonrails.com Screencast | http://peepcode.com
Hi Tim, On Jul 11, 2007, at 3:34 PM, Tim Fletcher wrote:> My opinion would be to keep it seperate so that in can be > usedelsewhere, but provide a hook into Markaby. So something along the > lines of this (completely untested):Thanks! That''s exactly what I needed. The whole implementation is now at: http://pastie.caboo.se/78442 This uses an Markaby::SVG11 tagset, which is at: http://pastie.caboo.se/78441 The only ugly bit is that Markaby defines "text" as the output command, which conflicts with the SVG tag named "text." I remember _why saying he was going to rename that method to "out" or something. Is that still planned? To use it, simply make sure that builder_svg is loaded, and do something like:> html do > head {title "Testing HTML+SVG"} > body do > p "Below is a wonderful example of" > a "SVG", :href => "http://www.w3.org/2000/svg" > svg do > title "Slide Title" > rect({:x=>2,:y=>2,:width=>508,:height=>318,:fill=>"aqua"}) > end > end > endI have a test suite, if anyone is interested. I haven''t done anything fancy yet, but it seems to all work. Is this something I should submit as a patch to Markaby itself? Best, -- Ernie P.