Created
March 26, 2014 11:12
-
-
Save tkawa/9781005 to your computer and use it in GitHub Desktop.
Railsのビューヘルパー内でHamlを使う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def render_thumbsup_button(options) | |
options[:url] ||= thumbsup_path | |
options[:method] ||= :put | |
options[:count] ||= 0 | |
# ローカル変数を渡したいときのみ locals が必要 | |
render inline: <<-HAML.strip_heredoc, type: :haml, locals: options | |
.thumbsup | |
= form_tag url, method: method do | |
%button.btn.btn-xs | |
= t('label.thumbsup') | |
- if count > 0 | |
.span.badge | |
%span.glyphicon.glyphicon-thumbs-up | |
%span= count | |
HAML | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment