Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Assets plugin and syntax

Started by Muut Archive 11 years ago · 9 replies · 833 views
11 years ago

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

11 years ago

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

11 years ago

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 ☆

11 years ago

@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

TXT
{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.

11 years ago

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

10 years ago

Sorry: ... still cannot use asset plugin

The following testing script is in /mytheme/js:

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

in template, it is called by:

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

or

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

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

TXT
     *... but nothing happens!*

nothing.

  • Even adding to new line base.html.twig like:

    TWIG
    {% 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.

10 years ago

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

10 years ago

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

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1366 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago