Skip to content

Commit

Permalink
Closes #323. Add language Swig with grammar HTML (Swig)
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed May 18, 2015
1 parent 5d085f0 commit 94fc870
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ notifications:
script: sh build-package.sh

env:
- APM_TEST_PACKAGES="language-typescript language-marko language-tss"
- APM_TEST_PACKAGES="language-typescript language-marko language-tss language-html-swig"

cache:
- pip
Expand Down
47 changes: 47 additions & 0 deletions examples/simple-jsbeautifyrc/swig/expected/test.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{# Comment #}

{# Unindented without and with HTML indentation#}
{% block blockname %}
<section>
<ul>
<li>TestText1</li>
</ul>
</section>
{% for foo in bar %}
{% if condition %}
<aside class="test1">
TestText2
</aside>
{% else %}
<div class="test2">
TestText3
</div>
{% endif %}
{% endfor %}
{% endblock %}

{# On the same line #}

{% set name = value %}

{% include "file" with context only %}

{% extends "file" %}

{# Indented wrong #}

{% parent %}

{% import "file" as varname %}

{% macro name args %}
TestText4
{% endmacro %}

{% tag %}
TestText5
{% end %}

{% autoescape on "js" %}
TestText6
{% endautoescape %}
43 changes: 43 additions & 0 deletions examples/simple-jsbeautifyrc/swig/original/_test.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{# Comment #}

{# Unindented without and with HTML indentation#}
{% block blockname %}
<section>
<ul>
<li>TestText1</li>
</ul>
</section>
{% for foo in bar %}
{% if condition %}
<aside class="test1">
TestText2
</aside>
{% else %}
<div class="test2">
TestText3
</div>
{% endif %}
{% endfor %}
{% endblock %}

{# On the same line #}

{% set name = value %} {% include "file" with context only %} {% extends "file" %}

{# Indented wrong #}

{% parent %}

{% import "file" as varname %}

{% macro name args %}
TestText4
{% endmacro %}

{% tag %}
TestText5
{% end %}

{% autoescape on "js" %}
TestText6
{% endautoescape %}
3 changes: 2 additions & 1 deletion spec/beautify-languages-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe "BeautifyLanguages", ->
"mustache", "objective-c", "perl", "php",
"python", "ruby", "sass", "sql",
"typescript", "xml", "csharp", "gfm", "marko",
"tss", "go"
"tss", "go", "html-swig"
]

beforeEach ->
Expand Down Expand Up @@ -134,6 +134,7 @@ describe "BeautifyLanguages", ->

beautifyCompleted = false
completionFun = (text) ->
# console.log(expectedTestPath, text) if ext is ".swig"
expect(text instanceof Error).not.toEqual(true, text)
# if text instanceof Error
# return beautifyCompleted = text # text == Error
Expand Down
3 changes: 2 additions & 1 deletion src/beautifiers/prettydiff.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = class PrettyDiff extends Beautifier
JSON: true
TSS: true
LESS: true
Swig: true
}

beautify: (text, language, options) ->
Expand All @@ -45,7 +46,7 @@ module.exports = class PrettyDiff extends Beautifier
when "EJS", "ERB", \
"Handlebars", "Mustache", \
# "Markup", "JSTL", "SGML", \ # Currently unsupported
"Spacebars", "XML"
"Spacebars", "XML", "Swig"
lang = "markup"
when "HTML"
lang = "html"
Expand Down
1 change: 1 addition & 0 deletions src/languages/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module.exports = class Languages
"scss"
"spacebars"
"sql"
"swig"
"tss"
"typescript"
"vala"
Expand Down
24 changes: 24 additions & 0 deletions src/languages/swig.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {

name: "Swig"
namespace: "swig"
fallback: ['html']

###
Supported Grammars
###
grammars: [
"HTML (Swig)"
"SWIG"
]

###
Supported extensions
###
extensions: [
'swig'
]

options: []

}

0 comments on commit 94fc870

Please sign in to comment.