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

Add jsbundle property to global metadata #5

Open
webketje opened this issue Aug 18, 2023 · 0 comments
Open

Add jsbundle property to global metadata #5

webketje opened this issue Aug 18, 2023 · 0 comments

Comments

@webketje
Copy link
Member

Adding jsbundle property to the global metadata with a structure jsbundle: { 'source-file.js': { src: 'destination-file.js', async: }}}.

This allows templates to do:

{% for script in jsbundle %}
<script {% for attr,value in script %} {{attr}}="{{value}}"{% endfor %}></script>
{% endfor %}

As well as use a mechanism whereby file front-matter specifies the scripts to load:

---
scripts:
  - 'assets/js/common/source.js'
  - 'assets/js/app/source.js':
     async: true
     integrity: 'abcdefg'
---
{% for script in jsbundle %}
{% if typeof script === 'string' %}
<script src="{{ script }}"></script>
{% else %}
<script {% for attr,value in script %} {{attr}}="{{value}}"{% endfor %}></script>
{% endfor %}
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

No branches or pull requests

1 participant