quickdraw/compilation_equivalence_cases/render_and_layouts.rb
Lines
100%20 of 20 covered
Branches
—0 of 0 covered
Methods
100%5 of 5 covered
| 1 | # frozen_string_literal: true | |
| 2 | ||
| 3 | 1 | module EquivalenceCases |
| 4 | 1 | module RenderAndLayouts |
| 5 | 1 | class Layout < Phlex::HTML |
| 6 | 1 | def view_template |
| 7 | 24 | html { body { main { yield } } } |
| 8 | end | |
| 9 | end | |
| 10 | ||
| 11 | 1 | class CaptureLayout < Phlex::HTML |
| 12 | 1 | def view_template |
| 13 | 18 | content = capture { yield } |
| 14 | 12 | div(class: "wrap") { raw safe(content) } |
| 15 | 12 | footer { "len=#{content.bytesize}" } |
| 16 | end | |
| 17 | end | |
| 18 | ||
| 19 | 1 | class Page < Phlex::HTML |
| 20 | 1 | def view_template |
| 21 | 9 | render Layout.new { div { "page" } } |
| 22 | 9 | render CaptureLayout.new { p { "captured" } } |
| 23 | 6 | render(CaptureLayout.new) { "plain text" } |
| 24 | end | |
| 25 | end | |
| 26 | ||
| 27 | 1 | class CaptureSelf < Phlex::HTML |
| 28 | 7 | def self.equivalence_scenarios = { "with block" => -> (klass) { klass.new.call { |c| c.span { "y" } } } } |
| 29 | ||
| 30 | 1 | def view_template |
| 31 | 8 | s = capture { yield } |
| 32 | 2 | pre { s } |
| 33 | end | |
| 34 | end | |
| 35 | end | |
| 36 | end |