no fallar si el sitio no tiene plantillas
This commit is contained in:
parent
1f377437e4
commit
abade15c23
2 changed files with 12 additions and 11 deletions
|
@ -111,7 +111,7 @@ class Site
|
|||
|
||||
# Obtiene todas las plantillas de artículos
|
||||
def templates
|
||||
@templates ||= posts_for('templates')
|
||||
@templates ||= posts_for('templates') || []
|
||||
end
|
||||
|
||||
# Obtiene todos los posts de una colección determinada
|
||||
|
|
|
@ -12,17 +12,18 @@
|
|||
.btn-group
|
||||
= link_to t('posts.new'), new_site_post_path(@site, lang: @lang),
|
||||
class: 'btn btn-success'
|
||||
%button.btn.btn-success.dropdown-toggle.dropdown-toggle-split{data: { toggle: 'split' },
|
||||
aria: { haspopup: 'true', expanded: 'false' }}
|
||||
%span.sr-only= t('posts.dropdown')
|
||||
.dropdown-menu
|
||||
- @site.templates.each do |template|
|
||||
= link_to template.id.camelize,
|
||||
new_site_post_path(@site, lang: @lang, template: template.id),
|
||||
- unless @site.templates.empty?
|
||||
%button.btn.btn-success.dropdown-toggle.dropdown-toggle-split{data: { toggle: 'split' },
|
||||
aria: { haspopup: 'true', expanded: 'false' }}
|
||||
%span.sr-only= t('posts.dropdown')
|
||||
.dropdown-menu
|
||||
- @site.templates.each do |template|
|
||||
= link_to template.id.camelize,
|
||||
new_site_post_path(@site, lang: @lang, template: template.id),
|
||||
class: 'dropdown-item'
|
||||
.dropdown-divider
|
||||
= link_to t('templates.index'), site_templates_path(@site),
|
||||
class: 'dropdown-item'
|
||||
.dropdown-divider
|
||||
= link_to t('templates.index'), site_templates_path(@site),
|
||||
class: 'dropdown-item'
|
||||
- @site.translations.each do |l|
|
||||
= link_to t("i18n.#{l}"), site_posts_path(@site, category: @category, lang: l),
|
||||
class: 'btn btn-info'
|
||||
|
|
Loading…
Reference in a new issue