Description
The README suggests that multiple custom plugin and button scripts can be loaded using the customJS option:
# Custom JS file.
# Usage: add custom plugins/buttons...
customJS: "/custom/js/path"
However, the src/Resources/views/Form/froala_widget.html.twig file currently only accommodates a single string for the froala_customJS variable:
{% if froala_customJS is defined %}
<script type="text/javascript" src="{{ asset( customJS ) }}"></script>
{% endif %}
Additionally, as referenced in Issue #127, the correct variable name passed to asset() should be froala_customJS.
Problem
This implementation does not allow for an array of scripts to be passed and iterated through, which limits flexibility for users who need to load multiple scripts.
Suggested Solution
Update the Twig template to handle both a single string and an array of scripts for froala_customJS. The logic should maintain backward compatibility, loading a single script if a string is provided or iterating through an array if multiple scripts are specified. Below is the proposed code update:
{% if froala_customJS is defined %}
{% if froala_customJS is iterable %}
{% for script in froala_customJS %}
<script type="text/javascript" src="{{ asset(script) }}"></script>
{% endfor %}
{% else %}
<script type="text/javascript" src="{{ asset(froala_customJS) }}"></script>
{% endif %}
{% endif %}
Benefits
- Supports both single string and array formats for froala_customJS.
- Maintains backward compatibility with existing implementations.
- Provides greater flexibility for users to load multiple custom plugins or buttons.
Description
The README suggests that multiple custom plugin and button scripts can be loaded using the customJS option:
However, the
src/Resources/views/Form/froala_widget.html.twigfile currently only accommodates a single string for the froala_customJS variable:{% if froala_customJS is defined %} <script type="text/javascript" src="{{ asset( customJS ) }}"></script> {% endif %}Additionally, as referenced in Issue #127, the correct variable name passed to asset() should be froala_customJS.
Problem
This implementation does not allow for an array of scripts to be passed and iterated through, which limits flexibility for users who need to load multiple scripts.
Suggested Solution
Update the Twig template to handle both a single string and an array of scripts for froala_customJS. The logic should maintain backward compatibility, loading a single script if a string is provided or iterating through an array if multiple scripts are specified. Below is the proposed code update:
{% if froala_customJS is defined %} {% if froala_customJS is iterable %} {% for script in froala_customJS %} <script type="text/javascript" src="{{ asset(script) }}"></script> {% endfor %} {% else %} <script type="text/javascript" src="{{ asset(froala_customJS) }}"></script> {% endif %} {% endif %}Benefits