mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-24 23:36:21 +00:00
27 lines
569 B
Ruby
27 lines
569 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ApplicationHelper
|
|
# 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
|
|
|
|
def sanitize_markdown(text, options = {})
|
|
sanitize(CommonMarker.render_html(text), options)
|
|
end
|
|
end
|