{{ asset:js file="theme::custom.js" group="default" }}
{{ asset:js file="theme::app.js" group="default" }}
{{ asset:render_js group="default" }}
{{ asset:render_js group="modules" }}
That's my code for my JavaScript, but when I load in production, it doesn't load the script tag. However, in system/cms/config/asset.php if I turn asset_min and asset_combine to false, then it loads the JS files individually, without combining or minifying.
But I want it to combine and minify.
Help?
You have to do has follow to render the JS assets :
{{ asset:js file="theme::custom.js" group="default" }}
{{ asset:js file="theme::app.js" group="default" }}
{{ asset:render group="default" }}
{{ asset:render group="modules" }}
I think asset:render_js don't actually works
I have been having a similar problem.
It turns out {{ asset:render_js }} doesn't work, however <?php Asset::render_js(); ?> does.
So, for anyone else having problems in PyroCMS 2.2 using render_js, try the following:
{{ asset:js file="theme::javascript_file.js" }}
<?php Asset::render_js(); ?>
Related
I am developing a static web application using Hugo with Docsy theme. I would like to add an condition within Docsy Partials code where I would like to append the mailTo: word to my .url if the .mail is set to true, when I try to do this then I get the following error:
/themes/docsy/layouts/partials/footer.html:36:34": execute of template failed at <.url>: can’t evaluate field url in type bool
Following is the code I am adding to my partials:
{{ $myUrl := "" }}
{{ with .mail }}
{{ $myUrl = print "mailTo:" .url }}
{{ else }}
{{ $myUrl = .url }}
{{ end }}
{{ $myUrl }}
If I add some test then everything would work perfectly:
{{ with .mail }}
TRUE
{{ else }}
FALSE
{{ end }}
I am quite new to the Hugo and Docsy theme so finding difficult to understand and fix it. Any help would be really appreciated.
You are not using with correct here: https://gohugo.io/functions/with/. I think you should use if here.
when I create the port on Jekyll admin
title: layout:
page comments: true
social-share: true
show-avatar:true
use_math: true
I want to create this as default how should I do it?
Copy paste into your new post. Most CMS editors do that for you (like CloudCannon).
The real solution would be to transform them into site variables, by adding them to _config.yml and calling them using {{ site.social-share }} instead of {{ page.social-share }}.
An advanced solution would be to check if there are page variables, like this:
{% if page.social-share != nil %}
{{ page.social-share }}
{% else %}
{{ site.social-share }}
{% endif %}
The short version: have you managed to use something like {{ page.title | cgi_escape }} in an {% include %}-ed partial?
Details follow:
I have a partial that I use like so:
{% include mainContainer.html %}
Works fine. Then, in that partial, try to display some liquid variables:
{{ page.title }} displays the title.
{{ page.content }} Displays the content.
{{ page.content | cgi_escape }} displays the content, but escaped.
{{ page.title | cgi_escape }} doesn't work at all. Creates the following error:
Liquid Exception: undefined method `encoding' for nil:NilClass
Aside from {{ page.content }} I get the error for any of the {{ page }} variables (category, title, etc) but all of them will display fine without the filter. Also, {{ page.title | cgi_escape }} works okay in the...uhhh...'content' part of the layout (I'm not sure what to call it--the {{ content }} section). I only seem to get the error with {% include %}
Nevermind. The build was failing because a few of the pages using {% include mainContainer.html %} didn't have any front matter and thus no page.title (or whatever). Apparently, Liquid is willing to let {{ page.title }} pass if the variable isn't set, but not {{ page.title | cgi_encode }}
{% autoescape false %}
{% set label = '<i class="flaticon solid plus-1"></i>Add User'|raw %}
{{ form_row(form.submit, { 'label': label }) }}
{% endautoescape %}
This is the output
<i class="flaticon solid plus-1"></i>Add User
How do I get it to not escape? If I just print out label instead of supplying it as a parameter to the "form_row" function, it prints out properly.
You're using the |raw filter at the wrong place - it is only processed when outputting data, not when setting a variable. You should patch it into the form_row function, or append it to it's call - can't be sure without seeing how that function works.
Most probably this will fix it:
{{ form_row(form.submit, { 'label': label })|raw }}
Since I assume it returns the modified string and lets the {{ tags handle output.
in form_div_layout.html.twig
change
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ label|trans({}, translation_domain) }}</button>
to
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ label|trans({}, translation_domain)|raw }}</button>
This seems like a hacky solution, since I'm modifying the stuff in the vendor folder.
I'm trying to get the image URL which is stored in the user module, using the following code:
{{ user:profile user_id="3" }}
{{ display_name }}
{{ company }}
{{ profile_picture }}
{{ /user:profile }}
{{ profile_picture }} is the image and all that appears as 'Array' on the page. The other variables appear as I would like them to, images have just been giving me problems. The image is properly store in the File module, I just can't seem to get it to appear on the page.
Any help would be appreciated
profile_picture is an array. You'll have to access the subelement of image if you want the image URL.
{{ user:profile user_id="3" }}
{{ profile_picture:image }}
{{ /user:profile }}