Assets plugin and syntax

Hi everybody ♪

I am not a expert developper therefore I am not able to understand in the documentation of the assets plugin where the assets has to be written in the example

Wouldn’t it be possible to change documentation a lit bit to make it more clear?

Thank you in advance

What do you need to do with your assets? What do you want to know?

Thanks for replying ♪

I am sorry for not understanding…

Where should I put an asset? ! ?

I mean: with the examples, I understand what it does … but I don’t know where I should place it?
Is it in the header of the markdown file of a page? …
In its body? …
In the base.html.twig ? …
Elsewhere? …

Its seems very powerful, but the examples are minimals…
I would like to know more to be able to understand the full power of it…

Thanks in advance for your help ☆

Assets are just in twig filters ?

@tidivoit To make the answer short Assets plugin allows you to add (inline) CSS and/or JS directly from your page content. Just for example in a page you write

{assets:css}
custom-style.css
{/assets}

to include a style file called custom-style.css into the page in the same folder as the page is located.

Thanks a lot ♪
I am going to try that.
It might solve my issue
It’s not exactly what I thought it would be but
Thanks a lot again

Sorry: … still cannot use asset plugin

The following testing script is in /mytheme/js:

<script>
alert('Hello, World!')
</script>

in template, it is called by:

{% do assets.add('theme://js/helloworld.js') %}

or

{% block javascripts %}
{% do assets.addJs('theme://js/helloworld.js' %}
{{ assets.js() }}
{% endblock %}

(in page.header,assets: is enabled: true)

     *... but nothing happens!*
  • Also tested method with in .md file:
{assets:inline_js}
alert('Hello, World!')
{/assets}
--- 
or

{assets:js order:10}
http://localhost/themes/mytheme/js/helloworld.js
{/assets}


nothing.

+ Even adding to new line `base.html.twig` like:

{% block javascripts %}
{% do assets.addJs(‘jquery’,101) %}
{% do assets.addJs(‘theme://js/modernizr.custom.71422.js’,100) %}
{% do assets.addJs(‘theme://js/featherlight.min.js’) %}
{% do assets.addJs(‘theme://js/clipboard.min.js’) %}
{% do assets.addJs(‘theme://js/jquery.scrollbar.min.js’) %}
{% do assets.addJs(‘theme://js/learn.js’) %}

    {% do assets.addJs('theme://js/helloworld.js') %}

    {{ assets.js() }}
{% endblock %}

does not work here.

There must be something wrong.... but what?

For the moment, I am dealing with TWIG passing every script in `.html.twig` extensions, but it is not really serious...

Any advice welcome.

Do you have CSS and/or JS pipelined turned on? If so, turn it off.

thank you (have a look at that)

@rhukster
No, CSS and/or JS pipelined are both turned off.