Closes #323. Add language Swig with grammar HTML (Swig)

This commit is contained in:
Glavin Wiechert 2015-05-18 18:08:06 -03:00
parent 5d085f0f5c
commit 94fc870b84
7 changed files with 120 additions and 3 deletions

View File

@ -16,7 +16,7 @@ notifications:
script: sh build-package.sh script: sh build-package.sh
env: env:
- APM_TEST_PACKAGES="language-typescript language-marko language-tss" - APM_TEST_PACKAGES="language-typescript language-marko language-tss language-html-swig"
cache: cache:
- pip - pip

View File

@ -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 %}

View File

@ -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 %}

View File

@ -21,7 +21,7 @@ describe "BeautifyLanguages", ->
"mustache", "objective-c", "perl", "php", "mustache", "objective-c", "perl", "php",
"python", "ruby", "sass", "sql", "python", "ruby", "sass", "sql",
"typescript", "xml", "csharp", "gfm", "marko", "typescript", "xml", "csharp", "gfm", "marko",
"tss", "go" "tss", "go", "html-swig"
] ]
beforeEach -> beforeEach ->
@ -134,6 +134,7 @@ describe "BeautifyLanguages", ->
beautifyCompleted = false beautifyCompleted = false
completionFun = (text) -> completionFun = (text) ->
# console.log(expectedTestPath, text) if ext is ".swig"
expect(text instanceof Error).not.toEqual(true, text) expect(text instanceof Error).not.toEqual(true, text)
# if text instanceof Error # if text instanceof Error
# return beautifyCompleted = text # text == Error # return beautifyCompleted = text # text == Error

View File

@ -29,6 +29,7 @@ module.exports = class PrettyDiff extends Beautifier
JSON: true JSON: true
TSS: true TSS: true
LESS: true LESS: true
Swig: true
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
@ -45,7 +46,7 @@ module.exports = class PrettyDiff extends Beautifier
when "EJS", "ERB", \ when "EJS", "ERB", \
"Handlebars", "Mustache", \ "Handlebars", "Mustache", \
# "Markup", "JSTL", "SGML", \ # Currently unsupported # "Markup", "JSTL", "SGML", \ # Currently unsupported
"Spacebars", "XML" "Spacebars", "XML", "Swig"
lang = "markup" lang = "markup"
when "HTML" when "HTML"
lang = "html" lang = "html"

View File

@ -49,6 +49,7 @@ module.exports = class Languages
"scss" "scss"
"spacebars" "spacebars"
"sql" "sql"
"swig"
"tss" "tss"
"typescript" "typescript"
"vala" "vala"

24
src/languages/swig.coffee Normal file
View File

@ -0,0 +1,24 @@
module.exports = {
name: "Swig"
namespace: "swig"
fallback: ['html']
###
Supported Grammars
###
grammars: [
"HTML (Swig)"
"SWIG"
]
###
Supported extensions
###
extensions: [
'swig'
]
options: []
}