fitztrev / laravel-html-minify

Minifies the HTML output of Laravel 4 applications
https://github.com/fitztrev/laravel-html-minify/wiki/Laravel-5---5.1-HTML-Minifying
MIT License
415 stars 76 forks source link

Error with Gulp html compress #59

Closed sakanaproductions closed 8 years ago

sakanaproductions commented 8 years ago

I'm getting the following error when running the gulp compress from your wiki:

[21:03:45] Starting 'compress'...

events.js:141 throw er; // Unhandled 'error' event ^ Error: Parse Error: <a class="btn btn-primary navbar-btn" <?php echo e($modelItem->isCreatable() ? '' : 'disabled'); ?> href="<?php echo e($newEntryRoute); ?>"> <?php echo e(Lang::get('admin::lang.table.new-entry')); ?>

renderTableAttributes(); ?>> renderHeader(); ?> ``` render($row, count($rows)); ?> isColumnFilter() && ! $modelItem->isAsync()): ?>
</div>



<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin::_layout.inner', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
grimmdude commented 8 years ago

I had the same issue; it's because of the nested PHP tags within the HTML tags. I opened this issue in the kangax/html-minifier repo and they updated it to include an option for ignoreCustomFragments.

https://github.com/kangax/html-minifier/issues/421

-Garrett

grimmdude commented 8 years ago

I updated the wiki in this repo to reflect this fix (hope owner doesn't mind). Also, be sure to update to the latest version of html-minifier.

-Garrett

grimmdude commented 8 years ago

Scratch that wiki update, just noticed the latest html-minifier ignores those custom fragments by default.

-G

sakanaproductions commented 8 years ago

@grimmdude okay, updated html-minifier and now getting this:

events.js:141 throw er; // Unhandled 'error' event ^ Error: Parse Error: <a {...this.props} href="javascript:;" role="button" className={(this.props.className || '') + ' btn'} data-keyboard="true" /> ); } });

grimmdude commented 8 years ago

I think the issue is with those embedded quotes in the className attribute. You'll need to write a regEx to ignore those {} blocks and use is in the ignoreCustomFragments option. Check this comment: https://github.com/kangax/html-minifier/issues/421#issuecomment-150911891

sakanaproductions commented 8 years ago

awesome, got it... i wasn't using Regex for ignoreCustomFragments... thanks again.