Ejemplo n.º 1
0
  /**
   * @see
   *     org.apache.velocity.runtime.directive.Directive#render(org.apache.velocity.context.InternalContextAdapter,
   *     java.io.Writer, org.apache.velocity.runtime.parser.node.Node)
   */
  @Override
  public boolean render(InternalContextAdapter context, Writer writer, Node node)
      throws IOException, ResourceNotFoundException, ParseErrorException,
          MethodInvocationException {

    //        String path = DirectiveUtil.getRequiredArgument(context,
    // node.jjtGetParent().jjtGetParent(), 0, getName());
    String path = DirectiveUtil.getRequiredArgument(context, node, 0, getName());

    List<String> cs;
    if (context.containsKey(DirectiveEnum.CSS.getCode())) {
      cs = (List<String>) context.get(DirectiveEnum.CSS.getCode());
    } else {
      cs = new ArrayList<String>();
      context.put(DirectiveEnum.CSS.getCode(), cs);
    }
    if (StringUtils.contains(path, ',')) {
      String[] paths = StringUtils.split(path, ',');
      cs.addAll(Arrays.asList(paths));
    } else {
      cs.add(path);
    }

    return true;
  }
Ejemplo n.º 2
0
 /** @see org.apache.velocity.runtime.directive.Directive#getName() */
 @Override
 public String getName() {
   return DirectiveEnum.CSS.name().toLowerCase();
 }