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

Add get() method to TempleContext #23

Open
maaaks opened this issue Dec 17, 2014 · 0 comments
Open

Add get() method to TempleContext #23

maaaks opened this issue Dec 17, 2014 · 0 comments

Comments

@maaaks
Copy link

maaaks commented Dec 17, 2014

Why don't you add a function like this into TempleContext? (This snippet does not work because of some Temple's template magic which I couldn't understand)

T get(T)(in string name, lazy T defValue=T.init)
{
    return (name in vars) ? vars[name].get!T : defValue;
}

It is for convenient usage like:

auto someBool = var.get!bool("someBool", false);  // parameter is false if not set
auto someInt  = var.get!int("someInt", -1);       // parameter is -1 if not set
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

1 participant