Splunk® Enterprise

Module System Reference

Splunk Enterprise version 7.2 is no longer supported as of April 30, 2021. See the Splunk Software Support Policy for details. For information about upgrading to a supported version, see How to upgrade Splunk Enterprise.
This documentation does not apply to the most recent version of Splunk® Enterprise. For documentation on the most recent version, go to the latest release.

Templates

add_script_block()

The add_script_block() method is a convenience expression that wraps the script_tags() template utility, which includes the contents of the caller body within a script block. This method is used by consumers to include template-specific JavaScript on template render.

Warning: Never inject user input into a call to add_script_block().

Synopsis

add_script_block()

Example

%page args="h"/><%namespace name="lib" file="//lib.html" import="*"/> <%call expr="lib.add_script_block()">

   alert('This alert will be included within a script block in this template');

</%call>

See Also

script_tags()

csrf_hidden_input()

The csrf_hidden_input() method is called within any HTML form that requires POST. This allows forms to comply with Splunk Web's CSRF protection scheme.

Note: Forms that POST but do not use this method are rejected.

Synopsis

csrf_hidden_input()

Example

<%page args="h"/><%namespace name="lib" file="//lib.html" import="*"/> <form action="${ make_url(someURI) }" method="post">

   ${csrf_hidden_input()}
   ... elided ...

css()

The css() method provides a convenience wrapper to the stylesheet_tags() template utility, permitting stylesheets to be included by the calling template. This method is used to include custom stylesheets to be included in a view.

Note: Use parent.css() to preserve parent stylesheets.

Synopsis

css()

Example

<%page args="h"/><%inherit file="//layout/view.html"/> <%namespace name="lib" file="//lib.html" import="*"/> <%def name="css()">

   <% parent.css() %>
   <%lib:stylesheet_tags files="${['/static/css/my_cool_styles1.css']}" />

</%def>

get_script_blocks()

The get_script_blocks() method renders any 'script_block' values within the attributes passed to the template as an argument.

Warning: Never inject user input into script blocks.

Synopsis

get_script_blocks()

Example

<%page args="h"/><%inherit file="//layout/view.html"/> <%namespace name="lib" file="//lib.html" import="*"/> <%lib:get_script_blocks /> <%doc>

   if the template was passed attributes['script_blocks'] with a 
   list value, each value will be injected into a script block.

</%doc>

script_tags()

The script_tags() method includes each of the specified files passed as a parameter. This method is most useful if your view requires custom or third-party JavaScript.

Warning: Never inject user input into script_tag() calls.

Synopsis

script_tags( files, compile)

Parameters

files Array List of files to be included in script source tags.
compile Boolean Deprecated

Example

<%page args="h"/><%inherit file="//layout/view.html"/> <%namespace name="lib" file="//lib.html" import="*"/>

<%lib:script_tags files="${['/static/js/foo.js', '/static/js/bar.js']}" />

See Also

add_script_block()

stylesheet_tags()

The stylesheet_tags() method includes each of the specified files in link tags. This method is most useful if your view requires custom or third-party CSS.

Warning: Never inject user input into stylesheet_tags() calls.

Synopsis

stylesheet_tags( files, compile, media)

Parameters

files Array List of files to be included in link tags.
compile Boolean Deprectated
media String (Optional) Media type:
all
screen
print

Example

<%page args="h"/><%inherit file="//layout/view.html"/> <%namespace name="lib" file="//lib.html" import="*"/>

<%lib:stylesheet_tags files="${['/static/css/foo.css', '/static/css/bar.css']}" />

Last modified on 12 August, 2019
Decorators   App Server Utilities

This documentation applies to the following versions of Splunk® Enterprise: 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.0.4, 7.0.5, 7.0.6, 7.0.7, 7.0.8, 7.0.9, 7.0.10, 7.0.11, 7.0.13, 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.1.6, 7.1.7, 7.1.8, 7.1.9, 7.1.10, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.2.8, 7.2.9, 7.2.10, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.3.6, 7.3.7, 7.3.8, 7.3.9


Was this topic useful?







You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters