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

Should be able to access previously executed templates/context in a variable template #68

Closed
mog13 opened this issue Feb 17, 2018 · 1 comment
Assignees

Comments

@mog13
Copy link
Owner

mog13 commented Feb 17, 2018

We should think about passing in some sort of context when a variable token is executed. This would allow functions to make decisions based on a previous templates outcome. I'm thinking along the lines of:

Splain.addEntry({colors:["red","green","blue"]});

let getCol = (context) =>{
    if(context.someWayToGetPreviousToken === "red") return "#ff0000";
    if(context.someWayToGetPreviousToken === "green") return "#00ff00";
    if(context.someWayToGetPreviousToken === "blue") return "#0000ff";
    return '#ffffff';
};

console.log(Splain.process("why not try {{colors}} ({{##getCol}})",{getCol}));

@luke-rogers luke-rogers self-assigned this Feb 18, 2018
@mog13
Copy link
Owner Author

mog13 commented Feb 19, 2018

closed via #70

@mog13 mog13 closed this as completed Feb 19, 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

No branches or pull requests

2 participants