Started working on IntrinsicHtml.
This commit is contained in:
parent
7e2e176e6a
commit
9c64a42038
@ -10,7 +10,7 @@ class Echo extends DelegatingWebViewComponent {
|
|||||||
|
|
||||||
static final ComponentFactory<Echo> FACTORY = new EchoFactory()
|
static final ComponentFactory<Echo> FACTORY = new EchoFactory()
|
||||||
|
|
||||||
private static final class EchoFactory implements ComponentFactory<Echo> {
|
protected static class EchoFactory implements ComponentFactory<Echo> {
|
||||||
|
|
||||||
Echo doCreate(String typeName) {
|
Echo doCreate(String typeName) {
|
||||||
doCreate(typeName, [:], true)
|
doCreate(typeName, [:], true)
|
||||||
@ -91,9 +91,14 @@ class Echo extends DelegatingWebViewComponent {
|
|||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
def entry = iter.next()
|
def entry = iter.next()
|
||||||
writer << entry.key
|
writer << entry.key
|
||||||
|
def value = entry.value
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
// no-op, because we already wrote the key
|
||||||
|
} else {
|
||||||
writer << '="'
|
writer << '="'
|
||||||
writer << entry.value
|
writer << value
|
||||||
writer << '"'
|
writer << '"'
|
||||||
|
}
|
||||||
if (iter.hasNext()) {
|
if (iter.hasNext()) {
|
||||||
writer << ' '
|
writer << ' '
|
||||||
}
|
}
|
||||||
|
@ -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> {
|
||||||
|
|
||||||
|
IntrinsicHtml doCreate(String typeName) {
|
||||||
|
new IntrinsicHtml([:], typeName, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
IntrinsicHtml doCreate(String typeName, boolean selfClose) {
|
||||||
|
new IntrinsicHtml([:], typeName, selfClose)
|
||||||
|
}
|
||||||
|
|
||||||
|
IntrinsicHtml doCreate(String typeName, Map<String, Object> attr) {
|
||||||
|
new IntrinsicHtml(attr, typeName, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
IntrinsicHtml doCreate(String typeName, Map<String, Object> attr, boolean selfClose) {
|
||||||
|
new IntrinsicHtml(attr, typeName, selfClose)
|
||||||
|
}
|
||||||
|
|
||||||
|
IntrinsicHtml doCreate(String typeName, Map<String, Object> attr, List<WebViewChildComponentRenderer> 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<String, Object> attr, String elementName, boolean selfClose) {
|
||||||
|
super(attr, elementName, selfClose)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user