Fluffless HTML creation syntax #3587
Closed
forthrin
started this conversation in
Feature requests
Replies: 1 comment
-
|
Nokogiri already supports this syntax, see https://nokogiri.org/rdoc/Nokogiri/XML/Builder.html #!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "nokogiri"
end
x = Nokogiri::HTML::Builder.new do
html do
head do
title 'My Website'
meta(charset: 'UTF-8')
link(rel: 'stylesheet', href: 'styles.css')
end
end
end
puts x.to_html
# => <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
# <html><head>
# <title>My Website</title>
# <meta charset="UTF-8">
# <link rel="stylesheet" href="styles.css">
# </head></html> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When using Nokogiri to build HTML, prefixing every single statement with
doccasts rather a gloom over things.There is this trick:
Is it possible to have this built into Nokogiri so one gets it for free?
Beta Was this translation helpful? Give feedback.
All reactions