[look at me im a bunch of provider logos. yippeeee]
` } -} \ No newline at end of file +} + +const instance = new Engine(); +export { + instance +}; \ No newline at end of file diff --git a/src/util/goop.ts b/src/util/goop.ts new file mode 100644 index 0000000..ea5ae2a --- /dev/null +++ b/src/util/goop.ts @@ -0,0 +1,8 @@ +/** + * Go json translator pretty much + * + * This is just cause I gotta stick to not touching Public templates + */ +export default function ungoop(obj: object) { + // TODO. will prob just use the type system +} diff --git a/test/util/gin.test.ts b/test/util/gin.test.ts index 9941bf1..c82abcb 100644 --- a/test/util/gin.test.ts +++ b/test/util/gin.test.ts @@ -1,26 +1,15 @@ -import { describe, it, expect } from 'bun:test' -import { Gin } from '../../src/util/gin' +import { describe, it, expect, beforeAll } from 'bun:test' +import { Engine } from '../../src/util/gin' describe('Gin template porting test', () => { - it('parse', async () => { - const example = - `Dear {{.Name}}, -{{if .Attended}} -It was a pleasure to see you at the wedding. -{{- else}} -It is a shame you couldn't make it to the wedding. -{{- end}} -{{with .Gift -}} -Thank you for the lovely {{.}}. -{{end}} -Best wishes, -Josie`; + const e = new Engine(); - const template = { - name: 'example', - root: Gin.parse(example) - }; + beforeAll(async () => { + await e.LoadHTMLGlob('examples/*html'); + e.printTemplates(); + }) + it('data', async () => { const data = [ { Name: 'Aunt Mildred', @@ -40,40 +29,31 @@ Josie`; ] const expected = - `Dear Aunt Mildred, +`Dear Aunt Mildred, It was a pleasure to see you at the wedding. Thank you for the lovely bone china tea set. Best wishes, Josie - Dear Uncle John, It is a shame you couldn't make it to the wedding. Thank you for the lovely moleskin pants. Best wishes, Josie - Dear Cousin Rodney, It is a shame you couldn't make it to the wedding. Best wishes, Josie` - const actual = data.map(r => Gin.execute(template, r)).join('\n\n'); - console.debug(Gin.execute(template, data[0])) + const actual = data.map(d => e.HTML("examples/data.html", d)).join('\n'); expect(actual).toEqual(expected); - }) - // it('parseGlob', async () => { - // const gin = new Gin(); - // const paths = await gin.parseGlob('public/**/*html'); - // }) - - // it('parseHTML', async () => { - // const gin = new Gin(); - // const text = await gin.parseHTML('public/pages/movie.html'); - // console.log(text); - // }) + it('define', async () => { + expect(e.HTML("T1", {})).toEqual('ONE') + expect(e.HTML("T2", {})).toEqual('TWO') + expect(e.HTML("T3", {})).toEqual('ONE TWO') + }) }) \ No newline at end of file