enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

Variables such as app.name in Pattern mappings #10369

Open ComLock opened 10 months ago

ComLock commented 10 months ago

In order to fix https://github.com/enonic/starter-tsup/issues/387 I need the ability to use app.name in a Pattern mapping. https://developer.enonic.com/docs/xp/stable/framework/mappings#pattern_mappings

Something like:

<mappings>
    <mapping controller="/site/static.js" order="50">
        <pattern>/_/static/${app.name}/.+</pattern>
    </mapping>
</mappings>

In js this would be a template literal string:

const pattern = `/_/static/${app.name}/.+`;
const re = new Regexp(pattern);
re.test(url);
rymsha commented 10 months ago

Workaround is to use Gradle ReplaceTokens filter https://docs.gradle.org/current/userguide/working_with_files.html#sec:filtering_files

ComLock commented 10 months ago

Side note: @sigdestad want's me to try using service in starter-tsup rather Pattern mapping.

That should probably work, but with less control over urls. Meaning a static resource will have multiple urls, even though we'll only use the shortest one (when generating urls)

ComLock commented 8 months ago

What about XP dev mode?