From c91f8f846c3c4e048b89e5479562bf224aac04f1 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sat, 19 Nov 2016 18:08:30 +0100 Subject: [PATCH] implements "@import (optional)" --- src/com/inet/lib/less/LessParser.java | 6 +++++- .../inet/lib/less/samples/general/importOptional.css | 12 ++++++++++++ .../lib/less/samples/general/importOptional.less | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/com/inet/lib/less/samples/general/importOptional.css create mode 100644 test/com/inet/lib/less/samples/general/importOptional.less diff --git a/src/com/inet/lib/less/LessParser.java b/src/com/inet/lib/less/LessParser.java index 95d0fa24..b7165af7 100644 --- a/src/com/inet/lib/less/LessParser.java +++ b/src/com/inet/lib/less/LessParser.java @@ -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; @@ -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; @@ -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 { diff --git a/test/com/inet/lib/less/samples/general/importOptional.css b/test/com/inet/lib/less/samples/general/importOptional.css new file mode 100644 index 00000000..b3bba7f6 --- /dev/null +++ b/test/com/inet/lib/less/samples/general/importOptional.css @@ -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); +} diff --git a/test/com/inet/lib/less/samples/general/importOptional.less b/test/com/inet/lib/less/samples/general/importOptional.less new file mode 100644 index 00000000..73e74358 --- /dev/null +++ b/test/com/inet/lib/less/samples/general/importOptional.less @@ -0,0 +1,2 @@ +@import (optional) "DoesNotExists.less"; +@import (optional) "slash.less";