File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,16 @@ Parameters with a `dataFile` property:
320320* have their ` default` set to the contents of the file
321321* given a default ` format` of ` hidden`
322322
323+ Additionally, the contents of the data file can be base64 encoded before being used as for ` default` by setting the ` base64` property to ` true ` :
324+
325+ ` ` ` yaml
326+ definitions:
327+ var:
328+ dataFile: example
329+ base64: true
330+ template: |
331+ {{var }}
332+ ` ` `
323333
324334## Development
325335
Original file line number Diff line number Diff line change @@ -410,7 +410,13 @@ class Template {
410410 if ( ! propDef . format ) {
411411 propDef . format = 'hidden' ;
412412 }
413- propDef . default = dataFiles [ propDef . dataFile ] ;
413+
414+ const dataFile = dataFiles [ propDef . dataFile ] ;
415+ if ( propDef . base64 ) {
416+ propDef . default = Buffer . from ( dataFile , 'utf8' ) . toString ( 'base64' ) ;
417+ } else {
418+ propDef . default = dataFile ;
419+ }
414420 delete propDef . dataFile ;
415421 }
416422 break ;
Original file line number Diff line number Diff line change @@ -1257,10 +1257,14 @@ describe('Template class tests', function () {
12571257 definitions:
12581258 fromFile:
12591259 dataFile: textData.txt
1260+ base64:
1261+ dataFile: textData.txt
1262+ base64: true
12601263 template: |-
12611264 {{fromFile}}
1265+ {{base64}}
12621266 ` ;
1263- const reference = 'Lorem ipsum\n' ;
1267+ const reference = 'Lorem ipsum\n\nTG9yZW0gaXBzdW0K ' ;
12641268 return Template . loadYaml ( yamldata , { dataProvider } )
12651269 . then ( ( tmpl ) => {
12661270 const schema = tmpl . getParametersSchema ( ) ;
@@ -1272,6 +1276,8 @@ describe('Template class tests', function () {
12721276 assert . strictEqual ( fileProp . format , 'hidden' ) ;
12731277 assert . strictEqual ( fileProp . default , 'Lorem ipsum\n' ) ;
12741278
1279+ assert . strictEqual ( schema . properties . base64 . default , 'TG9yZW0gaXBzdW0K' ) ;
1280+
12751281 const rendered = tmpl . render ( ) ;
12761282 console . log ( rendered ) ;
12771283 assert . strictEqual ( rendered , reference ) ;
You can’t perform that action at this time.
0 commit comments