azu / gitbook-plugin-include-codeblock

GitBook plugin for including file
Other
40 stars 25 forks source link

Fix template issue and downgrade feature #25

Closed azu closed 8 years ago

azu commented 8 years ago

This pull request fix #24 It is caused by spacing of template.

OK:

{{#if title}}
{{#if id}}
{% if file.type=="asciidoc" %}
> [[{{id}}]]link:{{originalPath}}[{{title}}]
{% else %}
> <a id="{{id}}" href="{{originalPath}}">{{title}}</a>
{% endif %}
{{else}}
{% if file.type=="asciidoc" %}
> [[{{title}}]]link:{{originalPath}}[{{title}}]
{% else %}
> <a id="{{title}}" href="{{originalPath}}">{{title}}</a>
{% endif %}
{{/if}}
{{else}}

NG:

{{#if title}}
    {{#if id}}
        {% if file.type=="asciidoc" %}
        > [[{{id}}]]link:{{originalPath}}[{{title}}]
        {% else %}
        > <a id="{{id}}" href="{{originalPath}}">{{title}}</a>
        {% endif %}
        {{else}}
        {% if file.type=="asciidoc" %}
        > [[{{title}}]]link:{{originalPath}}[{{title}}]
        {% else %}
        > <a id="{{title}}" href="{{originalPath}}">{{title}}</a>
        {% endif %}
    {{/if}}
{{else}}

I've removed space from template.

Refactor

e.g.)

[import](test.js)

to be

{% if file.type=="asciidoc" %}
> [[test.js]]link:test.js[test.js]
{% else %}
> <a id="test.js" href="test.js">test.js</a>
{% endif %}

``` javascript
console.log("test");