private void addComment(ST tmplt, ElementDefinition ed) { if(withComments && ed.hasShort() && !ed.getId().startsWith("Extension.")) { int nspaces; char[] sep; nspaces = Integer.max(COMMENT_COL - tmplt.add("comment", "#").render().indexOf('#'), MIN_COMMENT_SEP); tmplt.remove("comment"); sep = new char[nspaces]; Arrays.fill(sep, ' '); ArrayList<String> comment_lines = split_text(ed.getShort().replace("\n", " "), MAX_CHARS); StringBuilder comment = new StringBuilder("# "); char[] indent = new char[COMMENT_COL]; Arrays.fill(indent, ' '); for(int i = 0; i < comment_lines.size();) { comment.append(comment_lines.get(i++)); if(i < comment_lines.size()) comment.append("\n" + new String(indent) + "# "); } tmplt.add("comment", new String(sep) + comment.toString()); } else { tmplt.add("comment", " "); } }
private void set(ST template, String name, Object value) { template.remove(name); template.add(name, value); }
private void addComment(ST tmplt, ElementDefinition ed) { if(withComments && ed.hasShort() && !ed.getId().startsWith("Extension.")) { int nspaces; char[] sep; nspaces = Integer.max(COMMENT_COL - tmplt.add("comment", "#").render().indexOf('#'), MIN_COMMENT_SEP); tmplt.remove("comment"); sep = new char[nspaces]; Arrays.fill(sep, ' '); ArrayList<String> comment_lines = split_text(ed.getShort().replace("\n", " "), MAX_CHARS); StringBuilder comment = new StringBuilder("# "); char[] indent = new char[COMMENT_COL]; Arrays.fill(indent, ' '); for(int i = 0; i < comment_lines.size();) { comment.append(comment_lines.get(i++)); if(i < comment_lines.size()) comment.append("\n" + new String(indent) + "# "); } tmplt.add("comment", new String(sep) + comment.toString()); } else { tmplt.add("comment", " "); } }
@Override public void render( SpicyContext context, Writer output ) { try { for ( Map.Entry<String, Object> eachLocalAttribute : globalContext.entrySet() ) { st.add( eachLocalAttribute.getKey(), eachLocalAttribute.getValue() ); } for ( Map.Entry<String, Object> eachLocalAttribute : context.entrySet() ) { String key = eachLocalAttribute.getKey(); if ( st.getAttribute( key ) != null ) { st.remove( key ); } st.add( key, eachLocalAttribute.getValue() ); } output.write( st.render() ); } catch ( IOException ex ) { throw new SpicyPlatesFailure( "Unable to render StringTemplate template", ex ); } }
stateST.remove("needErrorClause"); eotST = edgeST;
stateST.remove("needErrorClause"); eotST = edgeST;