Menu icon Foundation

My Posts

  • 4
    Replies
  • Injecting global data into template

    By will hart

    data

    Ok so I am not sure I am wording this correctly, but the concept is we have a client with a fair number of locations.  Each has its own phone number, address, etc, etc. I want to work within the foundation email framework but not have a seperate... (continued)

    Last Reply by Ethan Hackett over 3 years ago


My Comments

will hart commented on will hart's post over 3 years

Ethan,
 
Thanks for the thought. Prior to this 2.0 release I was using a custom set up with some gulp env flags.  I decided to do the same with yargs. 
So I modified the package.json file to include another flag 
"scripts": {
"start": "gulp --dealer",
"build": "gulp --production --dealer"
}
Then my helper file info.js looks like 
import yargs from 'yargs';

module.exports = function(options) {

var selected = yargs.argv.dealer;
var dealer = options.data.root.dealers[selected];
var data = dealer[options.fn(this)];

return data;
}
I have a master data file in /data/ and make a call within template like 
<h2>{{#info}}name{{/info}}</h2>
<tel>{{#info}}phone{{/info}}</tel>
This seemed much easier than changing panini. So a sample run would be 
npm start hondaVirginia
 

Posts Followed

No Content

Following

    No Content

Followers

My Posts


My Comments

You commented on will hart's post over 3 years

Ethan,
 
Thanks for the thought. Prior to this 2.0 release I was using a custom set up with some gulp env flags.  I decided to do the same with yargs. 
So I modified the package.json file to include another flag 
"scripts": {
"start": "gulp --dealer",
"build": "gulp --production --dealer"
}
Then my helper file info.js looks like 
import yargs from 'yargs';

module.exports = function(options) {

var selected = yargs.argv.dealer;
var dealer = options.data.root.dealers[selected];
var data = dealer[options.fn(this)];

return data;
}
I have a master data file in /data/ and make a call within template like 
<h2>{{#info}}name{{/info}}</h2>
<tel>{{#info}}phone{{/info}}</tel>
This seemed much easier than changing panini. So a sample run would be 
npm start hondaVirginia
 

Posts Followed

No Content

Following

  • No Content

Followers

  • No Content