New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phlex::SVG #493
Phlex::SVG #493
Conversation
Co-Authored-By: Dave Kroondyk <21263+davekaro@users.noreply.github.com>
In HTML, SVG is considered a foreign element and must either have a start tag and an end tag, or a start tag that is marked as self-closing, in which case they must not have an end tag. See https://html.spec.whatwg.org/multipage/syntax.html#foreign-elements for details. Most (all?) of these SVG elements can have child elements too, mainly descriptive elements like ‘desc’, ‘metadata’ and ‘title’.
See 'https://www.w3.org/TR/SVG2/embedded.html#HTMLElements'. For these to work they need to use the HTML namespace like <html:video>.
This is looking really great. I will follow up with a closer review soon. |
lib/phlex/xml.rb
Outdated
end | ||
|
||
module Phlex | ||
class XML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this SGML
? https://en.wikipedia.org/wiki/Standard_Generalized_Markup_Language
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like SGML
is weird, because no one knows this by heart. Also Nokogiri uses XML
throughout their lib for representing XML and HTML nodes.
Or otherwise, also provide a XML < SGML
class 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users of Phlex probably don't need to know about the SGML
class, right? I think SGML
makes sense, and could see a future Phlex::XML
to generate strict XML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I would like to have a Phlex::XML
class for working with strict XML with support for namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough 👍🏼
I think this could do with a fair amount of refactoring, but it's a huge PR and it works and I’d like to merge it sooner rather than later so it doesn't get out of sync with other work. |
Following up on #492. Mostly adding the remaining SVG tags. Still needs more tests and work. SVG element list available https://www.w3.org/TR/SVG2/eltindex.html ### Example ```ruby class Icon < Phlex::SVG def template svg("viewBox" => "0 0 100 100" xmlns: "http://www.w3.org/2000/svg") do path(d: "M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z" ) end end end ``` The SVG tags are being removed from Phlex::HTML as they were a bit of a hack, but the `svg` tag now yields a new `Phlex::SVG` which can be used inline. ```ruby class Icon < Phlex::HTML def template svg("viewBox" => "0 0 100 100" xmlns: "http://www.w3.org/2000/svg") do |s| s.path(d: "M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z" ) } end end ``` --------- Co-authored-by: Joel Drapper <joel@drapper.me>
Following up on #492. Mostly adding the remaining SVG tags. Still needs more tests and work.
SVG element list available https://www.w3.org/TR/SVG2/eltindex.html
Example
The SVG tags
g
andpath
are being removed from Phlex::HTML as they were a bit of a hack, but thesvg
tag now yields a newPhlex::SVG
which can be used inline.