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

Adding support for Injected Data with Soy/Closure #150

Open
lpellegr opened this issue Dec 22, 2020 · 0 comments
Open

Adding support for Injected Data with Soy/Closure #150

lpellegr opened this issue Dec 22, 2020 · 0 comments

Comments

@lpellegr
Copy link
Contributor

lpellegr commented Dec 22, 2020

Closure Templates supports injected data, aka ij data:
https://github.com/google/closure-templates/blob/master/documentation/concepts/ij-data.md

Unfortunately, the current SoySauceViewsRenderer implementation provided by micronaut-views does not support custom ij data.

I would be happy to submit a PR but before going further I would like to get feedback from the maintainers regarding the changes.

Currently, SoySauceViewsRenderer retrieves the map returned in the request controller and set it as data in the SoySauce.Renderer renderer instance with setData:

My suggestion is to check if the Map returned by the request controller contains a key called ij. If so, the entry is removed and the value used as injected data (by simply appending entries to the existing ijOverlay Map). Here is a quick implementation overview:

final Object ijData = context.remove("ij");

if (ijData instanceof Map) {
    ijOverlay.putAll((Map<? extends String, ?>) ijData);
} else {
    LOG.warn("Skipping invalid ij value. Expected Map but got " + ijData.getClass());
}

What do you think about such a change? would you accept a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants