How to rewrite the javascript template string -


i'm trying modify code https://github.com/airblade/chartjs-ror/blob/master/vendor/assets/javascripts/chart.js

i need rewrite original string template tooltiptemplate: "<%=datasetlabel%> - <%= value %>", want add if else condition it.

but template string complex

how rewrite following logic ?

my rough logic is

if ( %value > 0) {%datasetlabel - %value} else {     %datasetlabel - "empty value" } 

% means variable in above logic

i guess can (untested code, idea):

yourtemplate: "<%if (value > 0){%>"    + "<%= datasetlabel - value %>"          + "<%}%>"                                + "<%else {%>"                           + "<%= datasetlabel - \"empty value\"%>" + "<%}%>" 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -