Skip to content

Instantly share code, notes, and snippets.

@yasuhito
Created March 23, 2019 04:12
Show Gist options
  • Save yasuhito/2b2e3dfd8742e1029d28c7b9be3b55dd to your computer and use it in GitHub Desktop.
Save yasuhito/2b2e3dfd8742e1029d28c7b9be3b55dd to your computer and use it in GitHub Desktop.
タイトルのヘルパ
module TitleHelper
def title(text: nil, size: nil, url: nil, spaced: false, &block)
body = text || capture(&block) || raise('Text is a mandatory.')
klass = CssClassString::Helper.new('title', "is-#{size}" => size, 'is-spaced' => spaced).to_s
if url
link_to body, url, class: klass
else
tag.__send__ "h#{size || 3}", body, class: klass
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment