tomyeh / ZUSS

An extension to CSS providing mixins, nested rules, conditional content, variables and seamless Java integration.
http://books.zkoss.org/wiki/ZUSS_Reference
19 stars 5 forks source link

Method for String interpolation #12

Closed jlangston closed 12 years ago

jlangston commented 12 years ago

With Less embedding a variable in a string is pretty easy with the @{token} syntax. Is there already a similar method to do this in zuss?

Less Example

@base-url: "http://assets.fnord.com";
background-image: url("@{base-url}/images/bg.png");
jlangston commented 12 years ago

I figured out a way to do this using the java method call feature

  public static String getCssBaseImgUri(String img)
  {
    return "'" + cssBaseImgUri + img + "'";
  }

cssBaseImgUri is a Static string which is the base image path for all the css images

@setImgPath(@imgName): @import packagepath.Class#getCssBaseImgUri;

body {
  background-image: url(@setImgPath(BodyBg.gif));
}
denizdogan commented 11 years ago

This issue should really be re-opened, since it's such a common requirement. Having to write custom Java code is quite off-putting.