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
|
# Obtiene todas las plantillas de artículos
|
||||||
def templates
|
def templates
|
||||||
@templates ||= posts_for('templates')
|
@templates ||= posts_for('templates') || []
|
||||||
end
|
end
|
||||||
|
|
||||||
# Obtiene todos los posts de una colección determinada
|
# Obtiene todos los posts de una colección determinada
|
||||||
|
|
|
@ -12,17 +12,18 @@
|
||||||
.btn-group
|
.btn-group
|
||||||
= link_to t('posts.new'), new_site_post_path(@site, lang: @lang),
|
= link_to t('posts.new'), new_site_post_path(@site, lang: @lang),
|
||||||
class: 'btn btn-success'
|
class: 'btn btn-success'
|
||||||
%button.btn.btn-success.dropdown-toggle.dropdown-toggle-split{data: { toggle: 'split' },
|
- unless @site.templates.empty?
|
||||||
aria: { haspopup: 'true', expanded: 'false' }}
|
%button.btn.btn-success.dropdown-toggle.dropdown-toggle-split{data: { toggle: 'split' },
|
||||||
%span.sr-only= t('posts.dropdown')
|
aria: { haspopup: 'true', expanded: 'false' }}
|
||||||
.dropdown-menu
|
%span.sr-only= t('posts.dropdown')
|
||||||
- @site.templates.each do |template|
|
.dropdown-menu
|
||||||
= link_to template.id.camelize,
|
- @site.templates.each do |template|
|
||||||
new_site_post_path(@site, lang: @lang, template: template.id),
|
= 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'
|
class: 'dropdown-item'
|
||||||
.dropdown-divider
|
|
||||||
= link_to t('templates.index'), site_templates_path(@site),
|
|
||||||
class: 'dropdown-item'
|
|
||||||
- @site.translations.each do |l|
|
- @site.translations.each do |l|
|
||||||
= link_to t("i18n.#{l}"), site_posts_path(@site, category: @category, lang: l),
|
= link_to t("i18n.#{l}"), site_posts_path(@site, category: @category, lang: l),
|
||||||
class: 'btn btn-info'
|
class: 'btn btn-info'
|
||||||
|
|
Loading…
Reference in a new issue