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
|
||||
|
||||
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|
|
||||
t.id == id
|
||||
end
|
||||
|
|
|
@ -63,6 +63,7 @@ class Post
|
|||
load_front_matter!
|
||||
merge_with_front_matter! front_matter.stringify_keys
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Limpiar los errores
|
||||
|
@ -222,6 +223,7 @@ class Post
|
|||
end
|
||||
|
||||
def template_fields
|
||||
return [] unless template
|
||||
@template_fields ||= template.front_matter.reject do |key, _|
|
||||
REJECT_FROM_TEMPLATE.include? key
|
||||
end.keys
|
||||
|
@ -312,7 +314,9 @@ class Post
|
|||
|
||||
# Completa el front_matter a partir de las variables de otro
|
||||
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
|
||||
ft = template.front_matter.dup
|
||||
|
|
Loading…
Reference in a new issue