G
G
Gosha Mann2014-07-21 13:28:16
HTML
Gosha Mann, 2014-07-21 13:28:16

How to ignore xtemplate syntax in html-minifier?

I am using xTemplate. The goal is to minimize code when building.
I use grunt + html-minifier.
my settings are like this:

htmlmin: { 
            dist: {                  
                options: {
                    removeComments: true,
                    collapseWhitespace: true,
                    minifyJS: true,
                    minifyCSS: true,
                    useShortDoctype: true,
                    removeCommentsFromCDATA: true,
ignoreCustomComments: [
                        /^\s+<!-- BEGIN/,
                        /\/ -->\s+$/,
                        /^\s+{/,
                        /^\s+}/
                    ]
                },
                expand: true,
                cwd: '.template/',
                src: ['*.xtpl'],
                dest: '.template/test/'
            }
        },

but on startup it throws an error
Warning: .template/page-assets-menu.xtpl
Parse Error: <option<!-- BEGIN: this --> selected="selected"<!-- END: this -->>{ROW.name}</option>
                    <!-- END: countries -->
                </select>
            </div>
        </div>

the syntax in this piece of code is as follows:
<option selected="selected">Все страны</option>
                    <!-- BEGIN: countries -->
                    <option<!-- BEGIN: this --> selected="selected"<!-- END: this -->>{ROW.name}</option>
                    <!-- END: countries -->

how to ignore this code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Melnikov, 2014-07-21
@mlnkv

try like this:

ignoreCustomComments: [
  /^\s+<!-- BEGIN/,
  / -->\s+$/,
  /^\s+{/,
  /^\s+}/
]

or like this:
ignoreCustomComments: [
  /<!-- BEGIN/,
  /-->/,
  /^\s+{/,
  /^\s+}/
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question