Maya Docs
  • Introducing Maya
  • Product
    • Command Bar
    • Workspaces
      • Importing JSON Workflows
    • Modules
      • Config Profiles
    • Node Library
      • Common
        • Inject
        • Debug
        • Complete
        • Catch
        • Status
      • Functions
        • Function
        • Change
        • Switch
        • Template
        • Range
        • Delay
        • Trigger
        • Filter
        • Exec
      • Storage
        • Read File
        • Modify File
        • Watch Files
      • Parser
        • CSV
        • HTML
        • JSON
        • XML
        • YAML
      • Sequence
        • Split Into Array
        • Join Array
        • Sort Array
        • Batch Messages
      • Dashboard
        • Button
        • Chart
        • Slider
        • Gauge
        • Switch
        • Dropdown
        • Numeric Input
        • Text Input
        • Template
        • Date Picker
        • Colour Picker
        • Form
        • Display Text
        • Audio Out
      • Network
        • Websockets
          • Websocket Out
          • Websocket In
        • HTTP
          • HTTP In
          • HTTP Response
          • HTTP Request
      • Command Bar
        • Bot Scheduler
        • Bot Command In
        • Bot Command Out
          • Bot Response
          • Bot Web Card
          • Bot Dash Card
        • Custom Search In
        • Custom Search Out
        • Bot Info
      • Spotify
        • Get Playback State
        • Control Playback
        • Play
        • Library
        • Playlist
        • Search
    • Web Extension
      • Selecting Elements
      • Making a web automation skill in 5 minutes
    • Troubleshooting
    • Changelog
  • Tutorials
    • Install skills/modules from store
    • Building fundamentals
    • Connect different services
      • Spotify + Figma
      • Zoom + Google Calendar
    • Browser Automation
      • Control YouTube - Easy
      • Scrape Twitter - Moderate
      • Manage Gmail Inbox - Hard
Powered by GitBook
On this page

Was this helpful?

  1. Product
  2. Node Library
  3. Dashboard

Template

Add any valid piece of HTML to the Maya dashboard.

The template widget can contain any valid html and Angular/Angular-Material directives.

This node can be used to create a dynamic user interface element that changes its appearance based on the input message, and can send messages back to Maya.

Will display if the number received as msg.payload is even or odd. It will also change the color of the text to green if the number is even or red if odd. The next example shows how to set a unique id for your template, pick up the default theme colour, and watch for any incoming message.

<div id="{{'my_'+$id}}" style="{{'color:'+theme.base_color}}">Some text</div>
<script>
(function(scope) {
  scope.$watch('msg', function(msg) {
    if (msg) {
      // Do something when msg arrives
      $("#my_"+scope.$id).html(msg.payload);
    }
  });
})(scope);
</script>

Templates made in this way can be copied and remain independent of each other.

Sending a message:

<script>
var value = "hello world";
// or overwrite value in your callback function ...
this.scope.action = function() { return value; }
</script>
<md-button ng-click="send({payload:action()})">
    Click me to send a hello world
</md-button>

Will display a button that when clicked will send a message with the payload 'Hello world'.

Using msg.template: You can also define the template content via msg.template, so you can use external files for example. Template will be reloaded on input if it has changed. Code written in the Template field will be ignored when msg.template is present.

PreviousText InputNextDate Picker

Last updated 3 years ago

Was this helpful?

The following icon fonts are available: (e.g. 'check', 'close') or a (e.g. 'fa-fire'), or a . You can use the full set of google material icons if you add 'mi-' to the icon name. e.g. 'mi-videogame_asset'.

Material Design icon
Font Awesome icon
Weather icon