Sha256: 9aca42151abf0188707f7e28dfef5e06029a2424fc8fd0dc349543a971702768

Contents?: true

Size: 529 Bytes

Versions: 3

Compression:

Stored size: 529 Bytes

Contents

# frozen_string_literal: true

module Components
	class Example < Phlex::View
		def initialize
			@sandbox = Module.new
		end

		def template(&block)
			render Tabs.new do |t|
				@t = t
				yield self
			end
		end

		def tab(name, code)
			@t.tab(name) do
				render CodeBlock.new(code, syntax: :ruby)
			end

			@sandbox.class_eval(code)
		end

		def execute(code)
			output = @sandbox.class_eval(code)

			@t.tab("HTML Output") do
				render CodeBlock.new(HtmlBeautifier.beautify(output), syntax: :html)
			end
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phlex-0.3.2 docs/components/example.rb
phlex-0.3.1 docs/components/example.rb
phlex-0.3.0 docs/components/example.rb