module Matestack::Ui::Core::TagHelper

Constants

TAGS
VOID_TAGS

can't take content or a block

Public Instance Methods

a(text = nil, options = {}, &block) click to toggle source
# File lib/matestack/ui/core/tag_helper.rb, line 53
def a(text = nil, options = {}, &block)
  # if :path attribut given rename to href
  if text.is_a?(Hash)
    text[:href] = text.delete(:path) if text[:href].nil?
  else
    options[:href] = options.delete(:path) if options[:href].nil?
  end
  Matestack::Ui::Core::Base.new(:a, text, options, &block)
end
heading(text = nil, options=nil, &block) click to toggle source

support old heading component

# File lib/matestack/ui/core/tag_helper.rb, line 64
def heading(text = nil, options=nil, &block)
  if text.is_a?(Hash)
    options = text
  end

  case options[:size]
  when 1
    h1(text, options, &block)
  when 2
    h2(text, options, &block)
  when 3
    h3(text, options, &block)
  when 4
    h4(text, options, &block)
  when 5
    h5(text, options, &block)
  when 6
    h6(text, options, &block)
  else
    h1(text, options, &block)
  end
end
img(text = nil, options = {}, &block) click to toggle source

override image in order to implement automatically using rails assets path

# File lib/matestack/ui/core/tag_helper.rb, line 45
def img(text = nil, options = {}, &block)
  # if :src attribut given try to replace automatically
  if src = text.delete(:path)
    text[:src] = ActionController::Base.helpers.asset_path(src)
  end
  Matestack::Ui::Core::Base.new(:img, text, options, &block)
end
matestack(&block) click to toggle source
# File lib/matestack/ui/core/tag_helper.rb, line 36
def matestack(&block)
  div(id: 'matestack-ui') do
    Base.new(:component, component_attributes) do
      div(class: 'matestack-app-wrapper', &block)
    end
  end
end
plain(text) click to toggle source
# File lib/matestack/ui/core/tag_helper.rb, line 27
def plain(text)
  Matestack::Ui::Core::Base.new(nil, text, nil)
end
rails_render(options = {}) click to toggle source
# File lib/matestack/ui/core/tag_helper.rb, line 87
def rails_render(options = {})
  plain render options
end
unescape(text) click to toggle source
# File lib/matestack/ui/core/tag_helper.rb, line 31
def unescape(text)
  Matestack::Ui::Core::Base.new(nil, text&.html_safe, escape: false)
end
Also aliased as: unescaped
unescaped(text)
Alias for: unescape