Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for default values, including in hiearchies #22

Merged
merged 4 commits into from
Feb 14, 2018

Conversation

dbouwman
Copy link
Member

@dbouwman dbouwman commented Feb 13, 2018

let template = {
    msg: 'Luke is {{obj.mood||happy}} with {{obj.friend||Jabba}}'
  }
var settings = {}
let result = adlib(template, settings)
// result.msg => 'Luke is happy with Jabba'

Supports strings, urls, int and float

Closes #21

lib/adlib.js Outdated
@@ -12,6 +12,7 @@ function isString(v) {

function _swap(parameter, settings, transforms) {
let value;
console.info(`_swap: param: ${parameter}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left this little guy behind

lib/adlib.js Outdated
let hbsEntries = templateValue.match(handlebars);

if (hbsEntries && hbsEntries.length) {
console.log(`Got a ${hbsEntries.length} handlebar entries...`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably remove this console.log

lib/adlib.js Outdated
let numberOfPaths = paths.length;
// here we check each option, in order, and return the first with a value in the hash, OR the last
path = paths.find((pathOption, idx) => {
console.info(`Checking to see if ${pathOption} is in settings hash...`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this logger

lib/adlib.js Outdated
values.forEach((v) => {
// console.log(`Comparing ${templateValue} with ${v.key}`)
if (templateValue == v.key) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was my mistake from earlier but this should probably be a ===

@dbouwman dbouwman merged commit 15edba0 into master Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants