0

I am getting below fatal error while using processhtml

Fatal error: month is not defined I think this is due to following html code in my page.

<div id="clndr" class="clearfix">
      <script type="text/template" id="clndr-template">
          <div class="clndr-controls">
              <div class="clndr-previous-button">&lt;</div>
              <div class="clndr-next-button">&gt;</div>
              <div class="current-month">
                  <%= month %>
                  <%= year %>
              </div>
          </div>
      </script>
    </div>

This is my grunt file processhtml:dist

processhtml: {
          dist:{
            options: {
              process: true,
            },
            files: [
            {
              expand: true,
              cwd: 'dist/',
              src: ['*.html'],
              dest: 'dist/',
              ext: '.html'
            },
            ],
          }
        },

Any solution for using processhtml with text/template.

Thanks in advance

Ajay Patel
  • 5,298
  • 11
  • 55
  • 87

1 Answers1

0

Finally after googling I found the solution.

on https://github.com/dciccale/grunt-processhtml they provide template settings https://github.com/dciccale/grunt-processhtml#optionstemplatesettings

I have used the same for underscore to fix this.

updated grunt command

processhtml: {
          dist:{
            options: {
              process: true,
              templateSettings: {
                  evaluate:    /{\{(.+?)\}\}/g,
                  interpolate: /{\{=(.+?)\}\}/g,
                  escape:      /{\{-(.+?)\}\}/g
              }
            },
            files: [
            {
              expand: true,
              cwd: 'dist/',
              src: ['*.html'],
              dest: 'dist/',
              ext: '.html'
            },
            ],
          }
        },
Ajay Patel
  • 5,298
  • 11
  • 55
  • 87