onyxframework / http

An opinionated framework for scalable web 🌎
https://onyxframework.com/http
MIT License
142 stars 11 forks source link

Add template renderer #57

Closed vladfaust closed 5 years ago

vladfaust commented 5 years ago

Should rely on Kilt, I guess.

require "kilt/liquid"

# With default values
liquid_renderer = Onyx::REST::Renderers::Template.new("text/html; charset=utf-8") do |error|
  render("./error.html.liquid")
end

# Or just
liquid_renderer = Onyx::REST::Renderers::Template.new

And with macros:

# With default values
Onyx.render(:liquid, "text/html; charset=utf-8") do |error|
  render("./error.html.liquid")
end

# Or just
Onyx.render(:liquid)

Expands to:

require "kilt/liquid"

renderer = Onyx::REST::Renderers::Template.new("text/html; charset=utf-8") do |error|
  render("./error.html.liquid")
end