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

additional transformation configuration #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbouzekri
Copy link

Hi,

I have this use case where my template is using a simple template engine. I would like to use your plugin to extract css and js from this template.

however they are written with this syntax :

<script src="{{ url_for('static', filename='components/moment/moment.js') }}"></script>
<script src="{{ url_for('static', filename='components/moment-timezone/builds/moment-timezone-with-data.min.js') }}"></script>

My proposal in this pull request is to add 3 additionnal config parameters :

  • js_regex : allow to override the default regex
  • css_regex : allow to override the default regex
  • clean : allow to define a function to process/transform the extracted filename from the HTML tag.

It could be used like this :

assets({
        js: 'appJs',
        css: false,
        js_regex: /<script.*?src=(?:")(.*?)(?:")/g,
        clean: function(value) {
            return value.replace('\'', 'aaaaa');
       }
});

Please tell me if you would be willing to merge something like that. If yes, I will update my pull request with all additional documentation.

Thanks in advance

Regards

@TCB13
Copy link

TCB13 commented Oct 3, 2016

@jbouzekri thanks for the awesome tweak! Can someone merge this? Ty!

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.

None yet

2 participants