-
-
Save willcosgrove/de49b01c966282b26154600a15f61fd0 to your computer and use it in GitHub Desktop.
Super duper forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'phlex' | |
end | |
class Field < Phlex::HTML | |
def template | |
p { "Field" } | |
end | |
end | |
class Form < Phlex::HTML | |
def field | |
Field.new | |
end | |
def template | |
p { "Form" } | |
yield if block_given? | |
end | |
end | |
class Page < Phlex::HTML | |
def template | |
render Form.new do |parent| | |
render parent.field | |
end | |
parent = Form.new | |
render parent.field | |
end | |
end | |
Page.new.call $stdout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment