Skip to content

Lambdas with "partial" partial evaluation #14

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

Open
marccelani opened this issue Sep 17, 2016 · 1 comment
Open

Lambdas with "partial" partial evaluation #14

marccelani opened this issue Sep 17, 2016 · 1 comment

Comments

@marccelani
Copy link

marccelani commented Sep 17, 2016

I have a partial..

partial.mustache

---

{{!...includes other things, but for simplicity...}}
{{! OptionalMarker}}

And an outer context which has a lambda...

{"ReplaceOptionalMarkers", mstch::lambda([](const std::string& text) -> mstch::node {
    auto result = text;
    boost::replace_all(result, "{{! OptionalMarker}}", "Rendered Optional!");
    return result;
  })}

I want to be able to do something like...

complete.mustache

---

{{#context:ReplaceOptionalMarkers}}{{> partial}}{{/context:ReplaceOptionalMarkers}}

Ideally, this would work even if partial includes other partials, and the marker is in those dependencies.

The feature I am asking for is to have a lambda function which "partially" realizes the partial. Rather than fully rendering the partial (which would lose the comment markers), it would replace the {{> partial}} in the string passed to the lambda with whatever is actually within partial, and recursively do so. User will need to avoid infinite loops.

The only alternative way I can imagine implementing something like this is by using global state and objects, which feels like the wrong pattern.

@marccelani
Copy link
Author

handlebars also does this better, because they support passing parameters to partials.

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