Mercurial Hosting > luan
comparison core/src/luan/modules/HtmlLuan.java @ 572:f1601a4ce1aa
fix stack when calling meta-methods
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 12 Jul 2015 21:34:23 -0600 |
parents | d9df6d6cb927 |
children | 7c3ad6db8ac3 |
comparison
equal
deleted
inserted
replaced
571:cd944b010f25 | 572:f1601a4ce1aa |
---|---|
280 for( Object o : html ) { | 280 for( Object o : html ) { |
281 if( o instanceof String ) { | 281 if( o instanceof String ) { |
282 buf.append( o ); | 282 buf.append( o ); |
283 } else if( o instanceof LuanTable ) { | 283 } else if( o instanceof LuanTable ) { |
284 LuanTable t = (LuanTable)o; | 284 LuanTable t = (LuanTable)o; |
285 String type = (String)t.get(luan,"type"); | 285 String type = (String)t.get(luan.JAVA,"type"); |
286 if( type==null ) | 286 if( type==null ) |
287 throw luan.exception( "no type in element of table for 'Html.to_string'" ); | 287 throw luan.exception( "no type in element of table for 'Html.to_string'" ); |
288 if( type.equals("comment") ) { | 288 if( type.equals("comment") ) { |
289 buf.append( "<!--" ).append( t.get(luan,"text") ).append( "-->" ); | 289 buf.append( "<!--" ).append( t.get(luan.JAVA,"text") ).append( "-->" ); |
290 } else if( type.equals("cdata") ) { | 290 } else if( type.equals("cdata") ) { |
291 buf.append( "<![CDATA[" ).append( t.get(luan,"text") ).append( "]]" ); | 291 buf.append( "<![CDATA[" ).append( t.get(luan.JAVA,"text") ).append( "]]" ); |
292 } else if( type.equals("tag") ) { | 292 } else if( type.equals("tag") ) { |
293 buf.append( tagToString(luan,t) ); | 293 buf.append( tagToString(luan,t) ); |
294 } else if( type.equals("container") ) { | 294 } else if( type.equals("container") ) { |
295 LuanTable tag = (LuanTable)t.get(luan,"tag"); | 295 LuanTable tag = (LuanTable)t.get(luan.JAVA,"tag"); |
296 buf.append( tagToString(luan,tag) ); | 296 buf.append( tagToString(luan,tag) ); |
297 buf.append( t.get(luan,"text") ); | 297 buf.append( t.get(luan.JAVA,"text") ); |
298 buf.append( "</" ).append( tag.get(luan,"name") ).append( ">" ); | 298 buf.append( "</" ).append( tag.get(luan.JAVA,"name") ).append( ">" ); |
299 } else { | 299 } else { |
300 throw luan.exception( "invalid element type for 'Html.to_string'" ); | 300 throw luan.exception( "invalid element type for 'Html.to_string'" ); |
301 } | 301 } |
302 } else | 302 } else |
303 throw luan.exception( "invalid value ("+Luan.type(o)+") in table for 'Html.to_string'" ); | 303 throw luan.exception( "invalid value ("+Luan.type(o)+") in table for 'Html.to_string'" ); |
306 } | 306 } |
307 | 307 |
308 private static String tagToString(LuanState luan,LuanTable tbl) throws LuanException { | 308 private static String tagToString(LuanState luan,LuanTable tbl) throws LuanException { |
309 StringBuilder buf = new StringBuilder(); | 309 StringBuilder buf = new StringBuilder(); |
310 buf.append('<'); | 310 buf.append('<'); |
311 buf.append(tbl.get(luan,"name")); | 311 buf.append(tbl.get(luan.JAVA,"name")); |
312 LuanTable attributes = (LuanTable)tbl.get(luan,"attributes"); | 312 LuanTable attributes = (LuanTable)tbl.get(luan.JAVA,"attributes"); |
313 for( Map.Entry<Object,Object> attr : attributes.iterable(luan) ) { | 313 for( Map.Entry<Object,Object> attr : attributes.iterable(luan.JAVA) ) { |
314 buf.append( ' ' ); | 314 buf.append( ' ' ); |
315 buf.append( attr.getKey() ); | 315 buf.append( attr.getKey() ); |
316 Object val = attr.getValue(); | 316 Object val = attr.getValue(); |
317 if( !val.equals(Boolean.TRUE) ) { | 317 if( !val.equals(Boolean.TRUE) ) { |
318 buf.append( '=' ); | 318 buf.append( '=' ); |
319 buf.append( quote((String)val) ); | 319 buf.append( quote((String)val) ); |
320 } | 320 } |
321 } | 321 } |
322 if( tbl.get(luan,"is_empty").equals(Boolean.TRUE) ) | 322 if( tbl.get(luan.JAVA,"is_empty").equals(Boolean.TRUE) ) |
323 buf.append('/'); | 323 buf.append('/'); |
324 buf.append('>'); | 324 buf.append('>'); |
325 return buf.toString(); | 325 return buf.toString(); |
326 } | 326 } |
327 | 327 |