Skip to content

Commit

Permalink
implements "@import (optional)"
Browse files Browse the repository at this point in the history
  • Loading branch information
Horcrux7 committed Nov 19, 2016
1 parent 389ca85 commit c91f8f8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/com/inet/lib/less/LessParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
package com.inet.lib.less;

import java.io.IOException;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -450,7 +451,6 @@ private void importFile( FormattableContainer currentRule, final String name ) {
break;
case "optional":
isOptional = true;
System.err.println( "not implemented @import keyword: " + keywordStr ); //TODO
break;
case "once":
isMultiple = false;
Expand Down Expand Up @@ -577,6 +577,10 @@ private void importFile( FormattableContainer currentRule, final String name ) {
}
} catch( LessException ex ) {
throw ex;
} catch( IOException ex ) {
if( !isOptional ) {
throw new LessException( ex );
}
} catch( Exception ex ) {
throw new LessException( ex );
} finally {
Expand Down
12 changes: 12 additions & 0 deletions test/com/inet/lib/less/samples/general/importOptional.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.slash {
a: 1.5;
b: 1.5;
e: a / b;
f: a / b;
g: a / b;
h: a / b;
}
.slash2 {
background: url("img.jpg") center / 100px;
background: url(abc/img.jpg);
}
2 changes: 2 additions & 0 deletions test/com/inet/lib/less/samples/general/importOptional.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import (optional) "DoesNotExists.less";
@import (optional) "slash.less";

0 comments on commit c91f8f8

Please sign in to comment.