2019-03-26 15:32:20 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-02 17:19:25 +00:00
|
|
|
module ApplicationHelper
|
2018-06-19 20:38:43 +00:00
|
|
|
# Devuelve el atributo name de un campo posiblemente anidado
|
|
|
|
def field_name_for_post(names)
|
|
|
|
return ['post', names] if names.is_a? String
|
|
|
|
|
|
|
|
names = names.dup
|
|
|
|
root = 'post'
|
|
|
|
name = names.pop
|
|
|
|
names.each do |n|
|
|
|
|
root = "#{root}[#{n}]"
|
|
|
|
end
|
|
|
|
|
|
|
|
[root, name]
|
|
|
|
end
|
|
|
|
|
|
|
|
def field_name_for_post_as_string(names)
|
|
|
|
f = field_name_for_post(names)
|
|
|
|
|
|
|
|
"#{f.first}[#{f.last}]"
|
|
|
|
end
|
2019-02-16 17:30:54 +00:00
|
|
|
|
|
|
|
def sanitize_markdown(text, options = {})
|
|
|
|
sanitize(CommonMarker.render_html(text), options)
|
|
|
|
end
|
2018-01-02 17:19:25 +00:00
|
|
|
end
|