Skip to content

Instantly share code, notes, and snippets.

@willcosgrove
Forked from bradgessler/test.rb
Created February 9, 2024 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willcosgrove/de49b01c966282b26154600a15f61fd0 to your computer and use it in GitHub Desktop.
Save willcosgrove/de49b01c966282b26154600a15f61fd0 to your computer and use it in GitHub Desktop.
Super duper forms
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