Skip to content

Conversation

@plyhun
Copy link
Contributor

@plyhun plyhun commented Dec 4, 2025

This is a heavy change, so formed as a POC, so no docu/changelog/fullfilling tests yet.

@plyhun plyhun requested a review from npomaroli December 4, 2025 12:18
.resolver(MapValueResolver.INSTANCE, JavaBeanValueResolver.INSTANCE)
.combine("cms", new ResolvableMapWrapper(renderType.getCMSResolver()))
.build();
ctx.combine("renderType", renderType);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need a rendertype around for the access to the expression parser.

Copy link
Member

Choose a reason for hiding this comment

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

The rendertype can be fetched from the current transaction, which is a threadlocal, so no need to inject it into the context.


getPartType(HandlebarsPartType.class, tag, HBS_PART_KEYWORD)
.getValueObject()
.setValueText(Arrays.stream(roles).map(role -> String.format("'%s'", role)).collect(Collectors.joining(",", "{{#gtx_store_expr '" + VTL_ROLES_FIELD + "'}}[", "]{{/gtx_store_expr}}")));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

{{#gtx_store_expr 'roles'}}
[
  'anonymous',
  'role_b'
]
{{/gtx_store_expr}}

can also be (less flexible) expressed as

{{{gtx_store 'roles' (gtx_expr "['anonymous','role_b']")}}}

Copy link
Member

@npomaroli npomaroli left a comment

Choose a reason for hiding this comment

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

I would like to have much more tests for this, and we should discuss, whether we want to add this as hotfix or as a new feature.

*/
public static Object gtx_expr(String input, Options options) throws ParserException, ExpressionParserException {
RenderType renderType = (RenderType) options.context.get("renderType");
return CnMapPublisher.parseExpression(renderType, input);
Copy link
Member

Choose a reason for hiding this comment

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

Do not use CnMapPublisher here, handlebars parts and publishing into a content repository are two separate things. Also this would make using the expression parser depend in the content repository specific feature "tagmap_useexpressionparser"

.resolver(MapValueResolver.INSTANCE, JavaBeanValueResolver.INSTANCE)
.combine("cms", new ResolvableMapWrapper(renderType.getCMSResolver()))
.build();
ctx.combine("renderType", renderType);
Copy link
Member

Choose a reason for hiding this comment

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

The rendertype can be fetched from the current transaction, which is a threadlocal, so no need to inject it into the context.

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