Confusing code - what is the meaning?

0

When I have this code:

{{ 'js/gourmet.js' | static_url | script_tag }}
  • What does it mean?
  • Where do I find this static_url ou o script_tag ?
  • Is this jQuery?
asked by anonymous 28.03.2017 / 14:50

1 answer

1

This looks like a template language. It can be Handlebars .

Basically the double keys tell the interpreter that this is a tag and needs to be replaced by valid HTML content.

There in case it probably imports a script tag with that URL.

What comes after pipes ("?") are filters applied to the content. It then has the js/gourmet content that passes through the static_url filter which probably places the rest of the URL as it is a static file and then the script_tag filter that probably encapsulates that URL in a script tag.

At the end of the day it should replace:

 <script src="http://site.com/assets/js/gourmet.js" />

In the first filter, it changes js/gourmet to the% static path of the file and in the second it adds the script tag.

There are several template languages with different patterns. This pattern of double keys came with Handlerbars and has been adapted by many frameworks like Angular for example.

    
29.03.2017 / 15:14