roborourke / wp-less

Provides a LESS compiler compatible with wp_enqueue_style() for rapid CSS development in themes and plugins.
MIT License
217 stars 55 forks source link

Parse Error #26

Closed BFTrick closed 11 years ago

BFTrick commented 11 years ago

Hello,

I'm using the less files from Twitter Bootstrap and whenever I update a less file I get this error exactly one time. After I get this error it doesn't appear again until change something in a less file.

parse error: failed at `@props: ~`"@{arguments}".replace(/[\[\]]|\,\sX/g, '')`;`
/path/to/my/site/wp-content/themes/my-theme/assets/css/less/mixins.less
on line 253

Here is line 253 from the mixins.less file.

.box-shadow(@shadowA, @shadowB:X, ...){
  // Multiple shadow solution from http://toekneestuck.com/blog/2012/05/15/less-css-arguments-variable/
  @props: ~`"@{arguments}".replace(/[\[\]]|\,\sX/g, '')`;
    -webkit-box-shadow: @props;
    -moz-box-shadow: @props;
    box-shadow: @props;
}

I've used Twitter Bootstrap and haven't had this problem so I'm assuming it is something to do with less. Any ideas what's going on?

roborourke commented 11 years ago

Hi Rauland,

The .replace() bit is a JavaScript method so not available in the PHP version. You'd have to remove the .replace() from the less and do it server side if possible.

You'd have to extend the less parser class with a replace function but I'm not sure of the exact code to do that right now!

Robert O'Rourke sanchothefat.com +44 7816 329424

roborourke commented 11 years ago

Sorry Patrick! Read your first name as Rauland for some reason... Long day.

Robert O'Rourke sanchothefat.com +44 7816 329424

BFTrick commented 11 years ago

Hi sanchothefat,

I don't know how to do that either and I'm not certain what will happen if we just remove it. With my basic understand of regex, I believe this replace function replaces all [, ] and , X with a null string. See here for an example. Why on earth does it do that?

Removing it is one option but obviously not having to modify Twitter Bootstrap would be easier. Any idea where to start looking?

roborourke commented 11 years ago

Well ideally I'd like to support twitter bootstrap out of the box but if they're relying on JavaScript it makes life rather difficult. Let me see if there's a ticket on the bootstrap repo

Robert O'Rourke sanchothefat.com +44 7816 329424

franz-josef-kaiser commented 11 years ago

Hey Patrick,

FYI, that's not the first time, they've released something that doesn't work. You'll just have to find a version that works and stick with it. Constantly updating TBS as submodule of your project doesn't seem to be the idea behind it. I'm currently also suffering from this.

BFTrick commented 11 years ago

I looked into Twitter Bootstrap and there are tons of people with this problem. It looks like they implemented a fix a couple versions ago. I'll download the latest version tomorrow and give it a run.

franz-josef-kaiser commented 11 years ago

Ok, so we can sum it up with blaiming TBS for using JS stuff that won't compile with LESSPHP/lesscPHP port.

roborourke commented 11 years ago

I'm going to mark this one as closed, if anyone else has a problem like this with the PHP version you'll have to edit the offending parts of TBS yourself, or switch to Foundation or https://github.com/sanchothefat/wp-sass & compass.