no fallar si no usamos una plantilla
This commit is contained in:
parent
6fa1edb4aa
commit
c0c0e060ce
2 changed files with 6 additions and 2 deletions
|
@ -39,7 +39,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_template(site)
|
def find_template(site)
|
||||||
id = params[:template_id] || params[:template] || params.require(:post).require(:layout)
|
id = params[:template_id] || params[:template] || params.dig(:post, :layout)
|
||||||
site.templates.find do |t|
|
site.templates.find do |t|
|
||||||
t.id == id
|
t.id == id
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,6 +63,7 @@ class Post
|
||||||
load_front_matter!
|
load_front_matter!
|
||||||
merge_with_front_matter! front_matter.stringify_keys
|
merge_with_front_matter! front_matter.stringify_keys
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Limpiar los errores
|
# Limpiar los errores
|
||||||
|
@ -222,6 +223,7 @@ class Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_fields
|
def template_fields
|
||||||
|
return [] unless template
|
||||||
@template_fields ||= template.front_matter.reject do |key, _|
|
@template_fields ||= template.front_matter.reject do |key, _|
|
||||||
REJECT_FROM_TEMPLATE.include? key
|
REJECT_FROM_TEMPLATE.include? key
|
||||||
end.keys
|
end.keys
|
||||||
|
@ -312,7 +314,9 @@ class Post
|
||||||
|
|
||||||
# Completa el front_matter a partir de las variables de otro
|
# Completa el front_matter a partir de las variables de otro
|
||||||
def front_matter_from_template
|
def front_matter_from_template
|
||||||
return {} unless template
|
# XXX: Llamamos a @template en lugar de template porque sino
|
||||||
|
# entramos en una race condition
|
||||||
|
return {} unless @template
|
||||||
|
|
||||||
# Convertimos el slug en layout
|
# Convertimos el slug en layout
|
||||||
ft = template.front_matter.dup
|
ft = template.front_matter.dup
|
||||||
|
|
Loading…
Reference in a new issue