Skip to content

Commit

Permalink
new convention for loops and string concat
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Apr 27, 2019
1 parent e2c1ebe commit 4c28900
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions packages/moon/dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@
}
} else {
var tag = "<" + token.value;
var attributes = token.attributes;

for (var attributeKey in token.attributes) {
var attributeValue = token.attributes[attributeKey];
for (var attributeKey in attributes) {
var attributeValue = attributes[attributeKey];
tag += " " + attributeKey + "=" + (isQuote(attributeValue[0]) ? attributeValue : "{" + attributeValue + "}");
}

Expand Down
11 changes: 6 additions & 5 deletions packages/moon/src/compiler/lexer/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function scopeExpression(expression) {
return expression.replace(expressionRE, (match, name) =>
(name === undefined || globals.indexOf(name) !== -1) ?
match :
`data.${name}`
"data." + name
);
}

Expand All @@ -57,10 +57,11 @@ export function tokenString(token) {
return `{${content}}`;
}
} else {
let tag = `<${token.value}`;
let tag = "<" + token.value;
const attributes = token.attributes;

for (let attributeKey in token.attributes) {
const attributeValue = token.attributes[attributeKey];
for (let attributeKey in attributes) {
const attributeValue = attributes[attributeKey];
tag += ` ${attributeKey}=${isQuote(attributeValue[0]) ? attributeValue : `{${attributeValue}}`}`;
}

Expand All @@ -84,7 +85,7 @@ export function tokenString(token) {
* @param {number} index
*/
function lexError(message, input, index) {
let lexMessage = `${message}\n\n`;
let lexMessage = message + "\n\n";

// Show input characters surrounding the source of the error.
for (
Expand Down
2 changes: 1 addition & 1 deletion packages/moon/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function Moon(options) {
}

if (typeof view === "string") {
view = new Function("data", `return ${compile(view)}`);
view = new Function("data", "return " + compile(view));
}

// If a `root` option is given, start the root renderer, or else just return
Expand Down
2 changes: 1 addition & 1 deletion packages/moon/src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function isQuote(char) {
* @param {string} message
*/
export function error(message) {
console.error(`[Moon] ERROR: ${message}`);
console.error("[Moon] ERROR: " + message);
}

/**
Expand Down

0 comments on commit 4c28900

Please sign in to comment.