-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(glimmer): initial HTML/Handlebars/Glimmer support * feat(glimmer): support un-escaped mustache expressions * fix(glimmer): add 'as |foo|' syntax * fix(glimmer): support {{foo bar}} syntax * feat(glimmer): implement all AST types * feat(glimmer): implement if/else if/else * test(glimmer): ignore leading/trailing whitespace from AST_COMPARE * fix(glimmer): do not use trailing slash for void self-closing elements * chore(build): disable html tests until we can sort out the glimmer dependency * feat(html): complete rebase on parse5 addition * Prettier Support For Glimmer VM/Handlebars Polished Support for Sub Expressions Added test cases for glimmer primitives Added support for concat statements Attempted to make element nodes work Attempted block statements Element Nodes are OK Added support for block elements that are not else-if related Added support for Else/If Cleaning up Rebase Switch node 4 syntax Update build * Removed dead code/partials * Added new lines to end of test files. * Rebase after plugin change * Added ignores to code coverage
- Loading branch information
1 parent
6a75f66
commit 833666a
Showing
35 changed files
with
1,346 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
|
||
const printer = require("./printer-glimmer"); | ||
|
||
// Based on: | ||
// https://github.com/github/linguist/blob/master/lib/linguist/languages.yml | ||
|
||
const languages = [ | ||
{ | ||
type: "markup", | ||
group: "HTML", | ||
aliases: ["hbs", "htmlbars"], | ||
extensions: [".handlebars", ".hbs"], | ||
tm_scope: "text.html.handlebars", | ||
ace_mode: "handlebars", | ||
language_id: 155 | ||
} | ||
]; | ||
|
||
const parsers = { | ||
glimmer: { | ||
get parse() { | ||
return eval("require")("./parser-glimmer"); | ||
}, | ||
astFormat: "glimmer" | ||
} | ||
}; | ||
|
||
const printers = { | ||
glimmer: printer | ||
}; | ||
|
||
module.exports = { | ||
languages, | ||
parsers, | ||
printers | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"use strict"; | ||
|
||
const createError = require("../common/parser-create-error"); | ||
function removeEmptyNodes(node) { | ||
return ( | ||
node.type !== "TextNode" || | ||
(node.type === "TextNode" && | ||
node.chars.replace(/^\s+/, "").replace(/\s+$/, "") !== "") | ||
); | ||
} | ||
function removeWhiteSpace() { | ||
return { | ||
visitor: { | ||
Program(node) { | ||
node.body = node.body.filter(removeEmptyNodes); | ||
}, | ||
ElementNode(node) { | ||
node.children = node.children.filter(removeEmptyNodes); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
function parse(text) { | ||
try { | ||
const glimmer = require("@glimmer/syntax").preprocess; | ||
return glimmer(text, { | ||
plugins: { | ||
ast: [removeWhiteSpace] | ||
} | ||
}); | ||
/* istanbul ignore next */ | ||
} catch (error) { | ||
const matches = error.message.match(/on line (\d+)/); | ||
if (matches) { | ||
throw createError(error.message, { | ||
start: { line: +matches[1], column: 0 }, | ||
end: { line: +matches[1], column: 80 } | ||
}); | ||
} else { | ||
throw error; | ||
} | ||
} | ||
} | ||
module.exports = parse; |
Oops, something went wrong.