Confusing code - what does it mean?

Asked

Viewed 102 times

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 ?
  • This is jQuery?
  • probably static_url and the script_tag are variable... but with only this line of code it will be difficult for anyone to help you.

  • That would be Angular?

1 answer

1

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

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

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

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

In the end he must replace it with:

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

On the first filter it changes js/gourmet for path static of the file and in the second adds the tag of script.

There are several template languages with several patterns. This double key pattern came with the Handlerbars and has been adapted by several frameworks such as Angular for example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.