Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handlebars parse error while compiling template

i am getting below error while compiling handlebars template with windows CMD. my handlebars client and server both are @1.3.0 please help me to identify where i am going wrong

dashboard.handlebars code--

<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2" style="text-align:center;">
    <li>

        <div class="chart" data-percent="{{#getPercent reward_point.point_achived reward_point.point_available}}">
            <span>{{#getPercent reward_point.point_achived reward_point.point_available}}%</span>
            <span style="font-size:.5em;display:inline-block;">{{reward_point.point_achived}}</span>
            <span style="font-size:.5em; color:#005390; display:inline-block;">/{{reward_point.point_available}} RP</span>
        </div>
    </li>
    <li>

        <div class="chart" data-percent="{{#getPercent calorie_budget.point_achived calorie_budget.point_available}}">
            <span>{{#getPercent calorie_budget.point_achived calorie_budget.point_available}}</span>
            <span style="font-size:.5em;display:inline-block;">{{calorie_budget.point_achived}}</span>
            <span style="font-size:.5em; color:#005390; display:inline-block;">/{{calorie_budget.point_available}} cal</span>
        </div>
    </li>
    <li>

        <div class="chart" data-percent="{{#getPercent 30_day_challenge.point_achived 30_day_challenge.point_available}}">
            <span>{{#getPercent 30_day_challenge.point_achived 30_day_challenge.point_available}}</span>
            <span style="font-size:.5em;display:inline-block;">{{30_day_challenge.point_achived}}</span>
            <span style="font-size:.5em; color:#005390; display:inline-block;">/{{30_day_challenge.point_available}} complete</span>
        </div>
    </li>
    <li>

        <div class="chart" data-percent="{{#getPercent physical_activity.point_achived physical_activity.point_available}}">
            <span>{{#getPercent physical_activity.point_achived physical_activity.point_available}}</span>
            <span style="font-size:.5em;display:inline-block;">{{physical_activity.point_achived}}</span>
            <span style="font-size:.5em; color:#005390; display:inline-block;">/{{physical_activity.point_available}} min</span>
        </div>
        </li>
</ul>

error in cmd--

Error: Parse error on line 34:
</ul>      </li>
----------------------^
Expecting 'CONTENT', 'COMMENT', 'OPEN_BLOCK', 'OPEN_INVERSE', 'OPEN_ENDBLOCK', '
OPEN', 'OPEN_UNESCAPED', 'OPEN_PARTIAL', got 'EOF'
    at Object.parseError (C:\Users\User\AppData\Roaming\npm\node_modules\handleb
ars\dist\cjs\handlebars\compiler\parser.js:107:11)
    at Object.parse (C:\Users\User\AppData\Roaming\npm\node_modules\handlebars\d
ist\cjs\handlebars\compiler\parser.js:159:22)
    at HandlebarsEnvironment.parse (C:\Users\User\AppData\Roaming\npm\node_modul
es\handlebars\dist\cjs\handlebars\compiler\base.js:12:17)
    at precompile (C:\Users\User\AppData\Roaming\npm\node_modules\handlebars\dis
t\cjs\handlebars\compiler\compiler.js:435:17)
    at HandlebarsEnvironment.hb.precompile (C:\Users\User\AppData\Roaming\npm\no
de_modules\handlebars\dist\cjs\handlebars.js:22:12)
    at processTemplate (C:\Users\User\AppData\Roaming\npm\node_modules\handlebar
s\bin\handlebars:188:78)
    at C:\Users\User\AppData\Roaming\npm\node_modules\handlebars\bin\handlebars:
194:3
    at Array.forEach (native)
    at Object.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\handle
bars\bin\handlebars:193:8)
    at Module._compile (module.js:456:26)
like image 245
Sandeep vashisth Avatar asked Jul 23 '14 05:07

Sandeep vashisth


People also ask

What is the use of compile in handlebars?

Handlebars.compile (template, options) Compiles a template so it can be executed immediately. const template = Handlebars.compile(" { {foo}}"); template({}); Supports a variety of options that alter how the template executes.

How do I execute a handlebars template?

These templates may be executed in the same manner as templates. If using the simple mode the precompiler will generate a single javascript method. To execute this method it must be passed to the Handlebars.template method and the resulting object may be used as normal.

What is the --knownonly option in handlebars?

The first allows you to specify a list of the known helpers to the compiler The Handlebars compiler will optimize accesses to those helpers for performance. When all helpers are known at compile time, the --knownOnly option provides the smallest generated code that also provides the fastest execution.

Can I integrate the handlebars precompiler into my Build System?

Some npm-packages can be used to integrate the Handlebars precompiler into your build system (i.e. Webpack, Browserify...). Have a look at the integrations page:


1 Answers

You are calling your getPercent-helper with a hash in front of it which makes it a block-statement which then in turn would need to be closed using {{/getPercent}}. Since there shouldn't be any need for it to be a block you probably could just remove the hash from your template.

<div class="chart" data-percent="{{getPercent reward_point.point_achived reward_point.point_available}}">
  <span>{{getPercent reward_point.point_achived reward_point.point_available}}%</span>
  <span style="font-size:.5em;display:inline-block;">{{reward_point.point_achived}}</span>
  <span style="font-size:.5em; color:#005390; display:inline-block;">/{{reward_point.point_available}} RP</span>
</div>
like image 74
Karl-Johan Sjögren Avatar answered Oct 10 '22 08:10

Karl-Johan Sjögren