Skip to content

Commit c91f8f8

Browse files
committed
implements "@import (optional)"
1 parent 389ca85 commit c91f8f8

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/com/inet/lib/less/LessParser.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727
package com.inet.lib.less;
2828

29+
import java.io.IOException;
2930
import java.io.Reader;
3031
import java.net.MalformedURLException;
3132
import java.net.URL;
@@ -450,7 +451,6 @@ private void importFile( FormattableContainer currentRule, final String name ) {
450451
break;
451452
case "optional":
452453
isOptional = true;
453-
System.err.println( "not implemented @import keyword: " + keywordStr ); //TODO
454454
break;
455455
case "once":
456456
isMultiple = false;
@@ -577,6 +577,10 @@ private void importFile( FormattableContainer currentRule, final String name ) {
577577
}
578578
} catch( LessException ex ) {
579579
throw ex;
580+
} catch( IOException ex ) {
581+
if( !isOptional ) {
582+
throw new LessException( ex );
583+
}
580584
} catch( Exception ex ) {
581585
throw new LessException( ex );
582586
} finally {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.slash {
2+
a: 1.5;
3+
b: 1.5;
4+
e: a / b;
5+
f: a / b;
6+
g: a / b;
7+
h: a / b;
8+
}
9+
.slash2 {
10+
background: url("img.jpg") center / 100px;
11+
background: url(abc/img.jpg);
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import (optional) "DoesNotExists.less";
2+
@import (optional) "slash.less";

0 commit comments

Comments
 (0)