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
Templating engine breaks SVG component scaled rendering by lowercasing viewBox attribute #256
Comments
After examining Based upon the above, it appears that SVG templates (and any others which need case-sensitive output) might render successfully by changing the properties applied to this object in The following script, when executed in .NET Fiddle, shows proper rendering of open HtmlAgilityPack
let svg = """<svg width="200" height="200" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="45" fill="${CircleFill}" stroke="${CircleStroke}" stroke-width="3"/>
</svg>"""
let svgDoc = new HtmlDocument()
svgDoc.OptionOutputOriginalCase <- true
svgDoc.LoadHtml(svg)
let svgBody = svgDoc.DocumentNode.SelectSingleNode("//svg")
printfn "%O" (svgBody.OuterHtml) |
When an element has no holes inside it, code generation uses HtmlNode.OuterHtml instead of HtmlAttribute.Name. So both cases must be checked.
When an element has no holes inside it, code generation uses HtmlNode.OuterHtml instead of HtmlAttribute.Name. So both cases must be checked.
When an element has no holes inside it, code generation uses HtmlNode.OuterHtml instead of HtmlAttribute.Name. So both cases must be checked.
Fixed in v0.20.17. |
TL;DR: SVGs use a
viewBox
attribute which is case-sensitive. This attribute is essential for rendering resizable images. The BoleroTemplate<>
implementation convertsviewBox
attributes toviewbox
(all lowercase), which breaks scaled rendering.Sample SVG
Below is a simple, hollow circle which renders to roughly fill a
200x200
area.Sample SVG Template
Below is the same SVG, but including Bolero Holes to specify the circle fill and stroke at runtime.
Rendered SVG Template
The template above, rendered by Bolero
0.20.12
, generates the following (copied using "copy element" in Edge developer tools):Working Example
A minimal example project exhibiting this behavio, based on the latest NuGet project template, can be seen at: https://github.com/JeremiahSanders/fsbolero-bolero-svg-viewbox.
The commit which modifies the template with the minimum changes to show this issue: https://github.com/JeremiahSanders/fsbolero-bolero-svg-viewbox/tree/f9281c33b8793dc0fb5a282659e975767831d738
The text was updated successfully, but these errors were encountered: