diff --git a/web-views/src/main/groovy/groowt/view/web/lib/Echo.groovy b/web-views/src/main/groovy/groowt/view/web/lib/Echo.groovy index 3161ef2..b3d1428 100644 --- a/web-views/src/main/groovy/groowt/view/web/lib/Echo.groovy +++ b/web-views/src/main/groovy/groowt/view/web/lib/Echo.groovy @@ -10,7 +10,7 @@ class Echo extends DelegatingWebViewComponent { static final ComponentFactory FACTORY = new EchoFactory() - private static final class EchoFactory implements ComponentFactory { + protected static class EchoFactory implements ComponentFactory { Echo doCreate(String typeName) { doCreate(typeName, [:], true) @@ -91,9 +91,14 @@ class Echo extends DelegatingWebViewComponent { while (iter.hasNext()) { def entry = iter.next() writer << entry.key - writer << '="' - writer << entry.value - writer << '"' + def value = entry.value + if (value instanceof Boolean) { + // no-op, because we already wrote the key + } else { + writer << '="' + writer << value + writer << '"' + } if (iter.hasNext()) { writer << ' ' } diff --git a/web-views/src/main/groovy/groowt/view/web/lib/IntrinsicHtml.groovy b/web-views/src/main/groovy/groowt/view/web/lib/IntrinsicHtml.groovy new file mode 100644 index 0000000..0412382 --- /dev/null +++ b/web-views/src/main/groovy/groowt/view/web/lib/IntrinsicHtml.groovy @@ -0,0 +1,50 @@ +package groowt.view.web.lib + +import groowt.view.component.context.ComponentContext +import groowt.view.component.factory.ComponentFactory +import groowt.view.web.WebViewChildComponentRenderer + +class IntrinsicHtml extends Echo { + + // TODO: check type name for HTML 5 validity + protected static class IntrinsicHtmlFactory implements ComponentFactory { + + IntrinsicHtml doCreate(String typeName) { + new IntrinsicHtml([:], typeName, false) + } + + IntrinsicHtml doCreate(String typeName, boolean selfClose) { + new IntrinsicHtml([:], typeName, selfClose) + } + + IntrinsicHtml doCreate(String typeName, Map attr) { + new IntrinsicHtml(attr, typeName, false) + } + + IntrinsicHtml doCreate(String typeName, Map attr, boolean selfClose) { + new IntrinsicHtml(attr, typeName, selfClose) + } + + IntrinsicHtml doCreate(String typeName, Map attr, List children) { + def intrinsicHtml = new IntrinsicHtml(attr, typeName, false) + intrinsicHtml.childRenderers = children + intrinsicHtml + } + + @Override + IntrinsicHtml create(String typeName, ComponentContext componentContext, Object... args) { + return this.doCreate(typeName, componentContext, *args) + } + + @Override + IntrinsicHtml create(Class type, ComponentContext componentContext, Object... args) { + throw new UnsupportedOperationException('Cannot create an IntrinsicHtml component with a class type.') + } + + } + + IntrinsicHtml(Map attr, String elementName, boolean selfClose) { + super(attr, elementName, selfClose) + } + +}