globalRenderOptions
globalRenderOptions
is an object that is passed into every template rendered by TweetDeck. This can be used to implement custom flags
and functions.
Contents
Current (default) contents of the global render options:
asset
: a function to return an asset viaTD.assets.get(value)
(perfect example for custom functions)decider
: all currently available deciders fromTD.decider.getAllWithOverlay()
featureFlag
: new TweetDeck features, looks like they are based on experimentsisTouchDevice
: TweetDeck determines if we are using a touch-enabled devicestyledScrollbar
: Determines if TweetDeck should show a styled or regular scrollbar
Functions can be used in templates like this:
{{#asset}}/web/assets/emoji/1f004.png{{/asset}}
/web/assets/emoji/1f004.png
is the value given to the function and will be inserted in whatever function is returned by the specific key
in globalRenderOptions
Flags can be used like this:
{{#isTouchDevice}}I'm a touch device{{/isTouchDevice}}
...where "I'm a touch device" only will be shown if isTouchDevice
is true.
Extending
Extending the global render options is an easy task. Just add another key to the object and either give it a boolean value to turn it into a flag, or give it a function that returns another function, passing the value of the template call into it.
Example for functions (asset
):
// ...
asset: function() {
return function(e) {
return TD.assets.get(e)
}
}
// ...
Templating in TweetDeck is based on Twitters hogan.js, so you'll be able to find more information there!
As always the notice that you should do this as early as possible, so stuff might not interfere with this or not be applied at all.