Sha256: c4a4178f4e3b8b5ee61df46a21ef3fedbc7719869d6e37e0eb57185c380fc14f
Contents?: true
Size: 756 Bytes
Versions: 1
Compression:
Stored size: 756 Bytes
Contents
# frozen_string_literal: true module Phlexible # # Create an alias at `element` to the `view_class`. # # So instead of: # # class MyView < Phlex::HTML # def template # div do # render My::Awesome::Component.new # end # end # end # # You can instead do: # # class MyView < Phlex::HTML # extend Phlexible::AliasView # # alias_view :awesome, -> { My::Awesome::Component } # # def template # div do # awesome # end # end # end # module AliasView def alias_view(element, view_class) define_method element do |*args, **kwargs, &block| render view_class.call.new(*args, **kwargs, &block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
phlexible-0.1.0 | lib/phlexible/alias_view.rb |