Skip to content

Commit

Permalink
Prevent template render errors when data is missing. Fixes #44.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgerigmeyer committed Dec 22, 2016
1 parent c0d9435 commit 8a30f9f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ for more info.
Releases
--------

### 0.5.3: 2016-12-22

- Prevent template render errors when data is missing. Fixes
[#44](https://github.com/oddbird/sassdoc-theme-herman/issues/44).


### 0.5.2: 2016-12-15

- Change absolute `@see` links to relative paths,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sassdoc-theme-herman",
"description": "An Odd SassDoc theme.",
"version": "0.5.2",
"version": "0.5.3",
"keywords": [
"sassdoc-theme"
],
Expand Down
4 changes: 2 additions & 2 deletions templates/item/macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


{% macro code_block(language=none, content=none) %}
{% set content = content if (content != none) else caller() %}
{% set content = caller() if caller else content %}
{% if content %}
{% set language = 'jinja' if language == 'njk' else language %}
{% set language = ['lang', language]|join('-') if language != none %}
{% set language = ['lang', language]|join('-') if language !== none %}
<pre data-sassdoc="hljs"><code{% if language %} class="{{ language }}"{% endif %}>{{ content }}</code></pre>
{% endif %}
{% endmacro %}
Expand Down
6 changes: 3 additions & 3 deletions templates/utility.macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


{% macro link_if(content=none, url=none, attrs={}) -%}
{%- set content = content if (content != none) else caller() -%}
{%- set content = caller() if caller else content -%}

{%- if url -%}
<a href="{{ url }}" {{ show_attrs(attrs) }}>{{ content }}</a>
Expand All @@ -42,14 +42,14 @@

{# Tabbed elements (see `static/js/app/base.js`) #}
{% macro tab(id, group, content=none, active=false) %}
{% set content = content if (content != none) else caller() %}
{%- set content = caller() if caller else content -%}
<a href="#panel-{{ id }}" data-sassdoc="example-tab" id="tab-{{ id }}" role="tab" data-tab-group="{{ group }}" data-contents="{{ id }}" aria-controls="panel-{{ id }}"{% if active %} aria-selected="true" tabindex="0"{% else %} tabindex="-1"{% endif %}>
{{ content }}
</a>
{% endmacro %}

{% macro tab_panel(id, group, content=none, active=false, class=none) %}
{% set content = content if (content != none) else caller() %}
{%- set content = caller() if caller else content -%}
<div data-sassdoc="example-panel" id="panel-{{ id }}" role="tabpanel" data-tab-group="{{ group }}" aria-labelledby="tab-{{ id }}" aria-hidden="{{ 'false' if active else 'true' }}" {{ attr_if('data-sassdoc-example-panel', class) }}>
{{ content }}
</div>
Expand Down

0 comments on commit 8a30f9f

Please sign in to comment.