Skip to content

Commit

Permalink
feat(parser): expose parseTokens method and make options public
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jul 12, 2018
1 parent 24418ab commit 3a30ff4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Parser {
ecmaVersion: 7,
}

constructor (public tags: { [key: string]: ITag }, private options: parserOptions) {
constructor (public tags: { [key: string]: ITag }, public options: parserOptions) {
}

/**
Expand Down Expand Up @@ -107,9 +107,15 @@ export class Parser {
* can be invoked using `new Function` keyword.
*/
public parseTemplate (template: string, wrapAsFunction: boolean = true): string {
const buffer = new EdgeBuffer()
const tokens = this.generateTokens(template)
return this.parseTokens(tokens)
}

/**
* Parses the lexer token to form a compiled template.
*/
public parseTokens (tokens, wrapAsFunction: boolean = true): string {
const buffer = new EdgeBuffer()
tokens.forEach((token) => (this.processToken(token, buffer)))
return buffer.flush(wrapAsFunction)
}
Expand Down

0 comments on commit 3a30ff4

Please sign in to comment.