Skip to content

Proposal: Pre-compiled js path and url support #22

Description

@Josiah

I'm proposing to build the routing functions (path and url) as javascript closures which will negate the need for any 3rd party libraries such as the FOSJsRoutingBundle.

If the parser were to provide the ability to define 'compiled functions' whereby instead of a function call, the behavior of the function is simulated in a closure or single use function.

Take the following scenario:

{# Twig Template #}
<a href="{{ path('foo_route', {bar: baz}) }}">Foo</a>
sb.append("<a href=\"");
sb.append((function(params){
    return "/foo/"+(params.bar||"");
})({bar: context ? context["baz"] : null});

The way that the route is comprised can be derived from the compiled route. Any need to share potentially sensitive routing information is negated by the fact that this would have been shared anyway as part of the template.

I'm happy to put some code to this if you're open to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions