|
1 | 1 | docX={} |
2 | | -docXData={} |
3 | 2 |
|
4 | 3 | expressions= require('angular-expressions') |
5 | 4 | angularParser= (tag) -> |
@@ -127,10 +126,10 @@ describe "DocxGenTemplatingForLoop", () -> |
127 | 126 | "prenom":"Edgar" |
128 | 127 | "telephone":"0652455478" |
129 | 128 | "description":"New Website" |
130 | | - "offre":[{"titre":"titre1","prix":"1250"},{"titre":"titre2","prix":"2000"},{"titre":"titre3","prix":"1400"}] |
| 129 | + "offre":[{"titre":"titre1","prix":"1250"},{"titre":"titre2","prix":"2000"},{"titre":"titre3","prix":"1400", "nom": "Offre"}] |
131 | 130 | docX['tagLoopExample.docx'].setTags Tags |
132 | 131 | docX['tagLoopExample.docx'].applyTags() |
133 | | - expect(docX['tagLoopExample.docx'].getFullText()).toEqual('Votre proposition commercialePrix: 1250Titre titre1Prix: 2000Titre titre2Prix: 1400Titre titre3HippEdgar') |
| 132 | + expect(docX['tagLoopExample.docx'].getFullText()).toEqual('Votre proposition commercialeHippPrix: 1250Titre titre1HippPrix: 2000Titre titre2OffrePrix: 1400Titre titre3HippEdgar') |
134 | 133 | it "should work with loops inside loops", () -> |
135 | 134 | Tags = {"products":[{"title":"Microsoft","name":"DOS","reference":"Win7","avantages":[{"title":"Everyone uses it","proof":[{"reason":"it is quite cheap"},{"reason":"it is quit simple"},{"reason":"it works on a lot of different Hardware"}]}]},{"title":"Linux","name":"Ubuntu","reference":"Ubuntu10","avantages":[{"title":"It's very powerful","proof":[{"reason":"the terminal is your friend"},{"reason":"Hello world"},{"reason":"it's free"}]}]},{"title":"Apple","name":"Mac","reference":"OSX","avantages":[{"title":"It's very easy","proof":[{"reason":"you can do a lot just with the mouse"},{"reason":"It's nicely designed"}]}]},]} |
136 | 135 | docX['tagProduitLoop.docx'].setTags Tags |
@@ -262,9 +261,7 @@ describe "getTags", () -> |
262 | 261 | it "should work with loop document", () -> |
263 | 262 | docX['tagLoopExample.docx']=new DocxGen docX['tagLoopExample.docx'].loadedContent,{},{intelligentTagging:off} |
264 | 263 | tempVars= docX['tagLoopExample.docx'].getTags() |
265 | | - expect(tempVars).toEqual([ { fileName : 'word/document.xml', vars : { offre : { prix : true, titre : true }, nom : true, prenom : true } }, { fileName : 'word/footer1.xml', vars : { nom : true, prenom : true, telephone : true } }, { fileName : 'word/header1.xml', vars : { nom : true, prenom : true } } ]) |
266 | | - |
267 | | - |
| 264 | + expect(tempVars).toEqual([ { fileName : 'word/document.xml', vars : { offre : { nom: true, prix : true, titre : true }, nom : true, prenom : true } }, { fileName : 'word/footer1.xml', vars : { nom : true, prenom : true, telephone : true } }, { fileName : 'word/header1.xml', vars : { nom : true, prenom : true } } ]) |
268 | 265 |
|
269 | 266 | describe "xmlTemplater", ()-> |
270 | 267 | it "should work with simpleContent", ()-> |
@@ -594,6 +591,17 @@ describe 'SubContent', () -> |
594 | 591 | xmlt=new DocXTemplater(content,{Tags:{name:"Henry"}}).applyTags() |
595 | 592 | expect(xmlt.content).toContain('Henry</w:t><w:t') |
596 | 593 |
|
| 594 | +describe 'getting parents context',()-> |
| 595 | + it 'should work with simple loops',()-> |
| 596 | + content= """{#loop}{name}{/loop}""" |
| 597 | + xmlt=new DocXTemplater(content,{Tags:{loop:[1],name:"Henry"}}).applyTags() |
| 598 | + expect(xmlt.content).toBe("Henry") |
| 599 | + |
| 600 | + it 'should work with double loops',()-> |
| 601 | + content= """{#loop_first}{#loop_second}{name_inner} {name_outer}{/loop_second}{/loop_first}""" |
| 602 | + xmlt=new DocXTemplater(content,{Tags:{loop_first:[1],loop_second:[{name_inner:"John"}],name_outer:"Henry"}}).applyTags() |
| 603 | + expect(xmlt.content).toBe("John Henry") |
| 604 | + |
597 | 605 | describe 'error messages', ()-> |
598 | 606 | it 'should work with unclosed', ()-> |
599 | 607 | content= """<w:t>{tag {age}</w:t>""" |
|
0 commit comments