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
env:
- APM_TEST_PACKAGES="language-typescript language-marko language-tss"
- APM_TEST_PACKAGES="language-typescript language-marko language-tss language-html-swig"
cache:
- 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",
"python", "ruby", "sass", "sql",
"typescript", "xml", "csharp", "gfm", "marko",
"tss", "go"
"tss", "go", "html-swig"
]
beforeEach ->
@ -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

View File

@ -29,6 +29,7 @@ module.exports = class PrettyDiff extends Beautifier
JSON: true
TSS: true
LESS: true
Swig: true
}
beautify: (text, language, options) ->
@ -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"

View File

@ -49,6 +49,7 @@ module.exports = class Languages
"scss"
"spacebars"
"sql"
"swig"
"tss"
"typescript"
"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: []
}