Skip to content

Add jsbundle property to global metadata #5

@webketje

Description

@webketje

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 %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions