Skip to content

Instantly share code, notes, and snippets.

@hampusn
Last active December 15, 2016 13:48
Show Gist options
  • Save hampusn/7b5a5bf53e159fd2eef80abdf0d913af to your computer and use it in GitHub Desktop.
Save hampusn/7b5a5bf53e159fd2eef80abdf0d913af to your computer and use it in GitHub Desktop.
script-module
/**
* [MODULE NAME]
*
* Limepark AB, 2016
*/
(function (window, document, $) {
// ...
// Document Ready
$(function () {
});
// Window Load
$(window).on('load', function () {
});
})(this, this.document, jQuery);
/**
* [MODULE DESCRIPTION]
*
* Limepark AB, 2016
*/
// sitevision < 4.2
if (typeof scriptVariables === 'undefined') var scriptVariables = {};
/**
* Contains configuration settings.
* @type {Object}
*/
var settings = {
"foo": (scriptVariables.foo !== null) ? scriptVariables.foo : 'tar',
"bar": (scriptVariables.bar !== null) ? scriptVariables.bar : true
};
/**
* Contains the main logic for this script module. Places needed
* variables in a context object accessible in the velocity template.
* @return {Object}
*/
var context = (function (request) {
var portletContextUtil = require('PortletContextUtil');
var endecUtil = require('EndecUtil');
var propertyUtil = require('PropertyUtil');
var resourceLocatorUtil = require('ResourceLocatorUtil');
var currentPage = portletContextUtil.getCurrentPage();
var currentPortlet = portletContextUtil.getCurrentPortlet();
// ...
return {
"foo": "bar"
};
})(request);
/*
=========================================================
[MODULE NAME]
=========================================================
* [MODULE DESCRIPTION]
*
* Limepark AB, 2016
=========================================================*/
/* ... */
## INIT ##
#set( $svUtils = $request.getAttribute('sitevision.utils') )
#set( $scriptUtil = $svUtils.scriptUtil )
#set( $endecUtil = $svUtils.endecUtil )
#set( $propertyUtil = $svUtils.propertyUtil )
## MAIN ##
<p>$context.foo</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment