How to add html-file with JavaScript code in template Slim?

user1134181 picture user1134181 · Feb 28, 2014 · Viewed 7.9k times · Source

There are HTML-file that contains JavaScript code. This JavaScript code loads an image and positioning it in a certain place. If failed, a message displays.

I need to include this file in template Slim.

I can include one Slim template to another by the following:

=render 'some/path/some_pattern'

How to include HTML- file to my template Slim?

Answer

Danny picture Danny · Feb 28, 2014

The best way to add some javascript to your slim file is either by including the javascript file using

= javascript_include_tag 'name of the file' 

or by directly adding the javascript code to your slim file, using

javascript:
  code line 1
  code line 2
  ...