diff --git a/.gitignore b/.gitignore
index 33e39b34..2e7e2db0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ node_modules
# pkg/transformjs
tmp
test/data/assets/
+test/data/**/*.zxcache
/package.json
/bun.lock
/src/cli/init/template/bun.lock
diff --git a/src/core/Transpile.zig b/src/core/Transpile.zig
index 24076dc2..1d3bc72a 100644
--- a/src/core/Transpile.zig
+++ b/src/core/Transpile.zig
@@ -501,7 +501,7 @@ pub fn transpileReturn(self: *Ast, node: ts.Node, ctx: *TranspileContext) !void
const allocator_value = try getAllocatorAttribute(self, child);
// Synthesized _zx init - no source mapping (it's boilerplate)
- try ctx.write("var _zx = @import(\"zx\").");
+ try ctx.write("var _zx = @import(\"zx\").x.");
if (allocator_value) |alloc| {
try ctx.write("allocInit(");
try ctx.write(alloc);
@@ -580,7 +580,7 @@ pub fn transpileBlock(self: *Ast, node: ts.Node, ctx: *TranspileContext) !void {
ctx.indent_level += 1;
try ctx.writeIndent();
- try ctx.write("var _zx = @import(\"zx\").");
+ try ctx.write("var _zx = @import(\"zx\").x.");
if (allocator_value) |alloc| {
try ctx.write("allocInit(");
try ctx.write(alloc);
diff --git a/src/root.zig b/src/root.zig
index e88e98b7..899f5146 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -8,13 +8,13 @@ const module_options = @import("zx_module_options");
const element = @import("element.zig");
const plfm = @import("platform.zig");
const prp = @import("props.zig");
-const z = @import("zx.zig");
const routing = @import("runtime/core/routing.zig");
const app_module = @import("runtime/server/Server.zig");
const opts = @import("options.zig");
const ctxs = @import("contexts.zig");
const reactivity = @import("runtime/client/reactivity.zig");
+const app_mod = @import("App.zig");
// -- Core Language --//
pub const Ast = if (!module_options.exclude_core_lang) @import("zx_core_lang").Ast else @compileError("core_lang is excluded. Set exclude-core-lang=false to enable.");
@@ -26,13 +26,9 @@ pub const sourcemap = if (!module_options.exclude_core_lang) @import("zx_core_la
pub const ElementTag = element.Tag;
pub const Component = @import("Component.zig").Component;
pub const Element = @import("Component.zig").Element;
-const ZxOptions = z.ZxOptions;
-pub const ZxContext = z.ZxContext;
-pub const zx = z.x;
-pub const lazy = z.lazy;
-pub const init = z.init;
-pub const allocInit = z.allocInit;
+// Internal - Used by the .zx -> .zig transpiler
+pub const x = @import("x.zig");
pub const routes = @import("zx_meta").routes;
pub const components = @import("zx_meta").components.components;
@@ -43,14 +39,12 @@ pub const info = @import("zx_info");
pub const Allocator = std.mem.Allocator;
pub const log = std.log;
+// TODO: Legacy, should be removed
pub const Server = app_module.Server;
-pub const Edge = @import("runtime/server/wasm/entrypoint.zig");
pub const Client = @import("runtime/client/Client.zig");
-const app_mod = @import("App.zig");
pub const App = app_mod.App;
pub const AppConfig = app_mod.Config;
-pub const allocator = app_mod.allocator;
// --- Namespaces --- //
pub const client = @import("runtime/client.zig");
@@ -92,8 +86,6 @@ pub const StateHandle = @import("runtime/core/Event.zig").StateHandle;
pub const BuiltinAttribute = @import("attributes.zig").builtin;
pub const Platform = plfm.Platform;
-pub const Os = plfm.Os;
-pub const Role = plfm.Role;
// --- Routing --- //
pub const Router = @import("runtime/core/Router.zig");
@@ -112,6 +104,7 @@ pub const Socket = routing.Socket;
pub const fetch = Fetch.fetch;
// --- Values --- //
+pub const allocator = app_mod.allocator;
pub const platform: Platform = plfm.platform;
pub const std_options: std.Options = opts.std_options;
diff --git a/src/runtime/core/Headers.zig b/src/runtime/core/Headers.zig
index feaa3759..8ba2b8ae 100644
--- a/src/runtime/core/Headers.zig
+++ b/src/runtime/core/Headers.zig
@@ -1,33 +1,18 @@
-//! MDN Web API compliant Headers abstraction.
-//! This module is backend-agnostic. The actual implementation is provided via vtable.
-//! https://developer.mozilla.org/en-US/docs/Web/API/Headers
-
const std = @import("std");
const common = @import("common.zig");
pub const Headers = @This();
-// Re-export types from std.http
pub const Header = common.Header;
-/// @deprecated Use `Header` instead.
-pub const Entry = Header;
/// HTTP header iterator for parsing raw header bytes.
-/// Re-exported from std.http.HeaderIterator for convenience.
///
/// This is useful when you have raw HTTP protocol bytes and need to parse headers.
/// For iterating over headers from a backend, use the `entries()` method which
/// returns the vtable-based `Iterator`.
-///
-/// [Zig std.http Reference](https://ziglang.org/documentation/master/std/#std.http.HeaderIterator)
pub const HeaderIterator = std.http.HeaderIterator;
-// --- Headers Data --- //
-
-/// Backend-specific context pointer (null for WASM/client-side)
backend_ctx: ?*anyopaque = null,
-
-/// VTable for backend-specific operations
vtable: ?*const VTable = null,
/// Whether this Headers instance is read-only (from request)
@@ -69,6 +54,7 @@ pub fn has(self: *const Headers, name: []const u8) bool {
}
/// Appends a new value onto an existing header (response only, no-op for request).
+///
/// https://developer.mozilla.org/en-US/docs/Web/API/Headers/append
pub fn append(self: *Headers, name: []const u8, value: []const u8) void {
if (self.read_only) return;
@@ -80,6 +66,7 @@ pub fn append(self: *Headers, name: []const u8, value: []const u8) void {
}
/// Sets a header value (response only, no-op for request).
+///
/// https://developer.mozilla.org/en-US/docs/Web/API/Headers/set
pub fn set(self: *Headers, name: []const u8, value: []const u8) void {
if (self.read_only) return;
@@ -91,6 +78,7 @@ pub fn set(self: *Headers, name: []const u8, value: []const u8) void {
}
/// Deletes a header. Note: Most backends don't support header deletion.
+///
/// https://developer.mozilla.org/en-US/docs/Web/API/Headers/delete
pub fn delete(self: *Headers, name: []const u8) void {
_ = self;
@@ -109,6 +97,7 @@ pub fn entries(self: *const Headers) ?Iterator {
}
/// Executes a provided function once for each header.
+///
/// https://developer.mozilla.org/en-US/docs/Web/API/Headers/forEach
pub fn forEach(self: *const Headers, callback: *const fn (value: []const u8, key: []const u8) void) void {
if (self.entries()) |*iter| {
@@ -119,18 +108,6 @@ pub fn forEach(self: *const Headers, callback: *const fn (value: []const u8, key
}
}
-// --- Iterator (vtable-based, for backend abstraction) --- //
-
-/// Backend-agnostic iterator for iterating over headers.
-///
-/// Example:
-/// ```zig
-/// if (headers.entries()) |*iter| {
-/// while (iter.next()) |header| {
-/// std.debug.print("{s}: {s}\n", .{ header.name, header.value });
-/// }
-/// }
-/// ```
pub const Iterator = struct {
backend_ctx: ?*anyopaque = null,
nextFn: ?*const fn (ctx: *anyopaque) ?Header = null,
diff --git a/src/zx.zig b/src/x.zig
similarity index 92%
rename from src/zx.zig
rename to src/x.zig
index acb7f697..665c6132 100644
--- a/src/zx.zig
+++ b/src/x.zig
@@ -26,7 +26,7 @@ pub const ComponentClientOptions = struct {
id: []const u8,
};
-const ZxOptions = struct {
+const Options = struct {
children: ?[]const Component = null,
attributes: ?[]const Element.Attribute = null,
allocator: ?std.mem.Allocator = null,
@@ -41,25 +41,17 @@ const ZxOptions = struct {
name: ?[]const u8 = null,
};
-/// Initialize a ZxContext without an allocator
+/// Initialize a Context without an allocator
/// The allocator must be provided via @allocator attribute on the parent element
-pub fn init() ZxContext {
+pub fn init() Context {
return .{ .allocator = std.heap.page_allocator };
}
-/// Initialize a ZxContext with an allocator (for backward compatibility with direct API usage)
-pub fn allocInit(allocator: std.mem.Allocator) ZxContext {
+/// Initialize a Context with an allocator (for backward compatibility with direct API usage)
+pub fn allocInit(allocator: std.mem.Allocator) Context {
return .{ .allocator = allocator };
}
-pub fn x(tag: ElementTag, options: ZxOptions) Component {
- return .{ .element = .{
- .tag = tag,
- .children = options.children,
- .attributes = options.attributes,
- } };
-}
-
/// Create a lazy component from a function
/// The function will be invoked during rendering, allowing for dynamic slot handling
/// Supports functions with 0 params (), 1 param (allocator), or 2 params (allocator, props)
@@ -68,14 +60,14 @@ pub fn lazy(allocator: Allocator, comptime func: anytype, props: anytype) Compon
}
/// Context for creating components with allocator support
-pub const ZxContext = struct {
+const Context = struct {
allocator: ?std.mem.Allocator = null,
- pub fn getAlloc(self: *ZxContext) std.mem.Allocator {
+ pub fn getAlloc(self: *Context) std.mem.Allocator {
return self.allocator orelse @panic("Allocator not set. Please provide @allocator attribute to the parent element.");
}
- fn escapeHtml(self: *ZxContext, text: []const u8) []const u8 {
+ fn escapeHtml(self: *Context, text: []const u8) []const u8 {
// On browser, DOM APIs (textContent) handle escaping automatically
// We only need to escape when generating HTML strings on the server
// TODO: we would want to move the escaping logic at the time of rendering the element, and simply not use escapeHtml for client side rendering
@@ -90,7 +82,7 @@ pub const ZxContext = struct {
return allocator.dupe(u8, aw.written()) catch @panic("OOM");
}
- pub fn ele(self: *ZxContext, tag: ElementTag, options: ZxOptions) Component {
+ pub fn ele(self: *Context, tag: ElementTag, options: Options) Component {
// Set allocator from @allocator option if provided
if (options.allocator) |allocator| {
self.allocator = allocator;
@@ -123,12 +115,12 @@ pub const ZxContext = struct {
} };
}
- pub fn txt(self: *ZxContext, text: []const u8) Component {
+ pub fn txt(self: *Context, text: []const u8) Component {
const escaped = self.escapeHtml(text);
return .{ .text = escaped };
}
- pub fn expr(self: *ZxContext, val: anytype) Component {
+ pub fn expr(self: *Context, val: anytype) Component {
const T = @TypeOf(val);
if (T == Component) return val;
@@ -209,13 +201,13 @@ pub const ZxContext = struct {
return Cmp;
}
- pub fn fmt(self: *ZxContext, comptime format: []const u8, args: anytype) Component {
+ pub fn fmt(self: *Context, comptime format: []const u8, args: anytype) Component {
const allocator = self.getAlloc();
const text = std.fmt.allocPrint(allocator, format, args) catch @panic("OOM");
return .{ .text = text };
}
- pub fn printf(self: *ZxContext, comptime format: []const u8, args: anytype) []const u8 {
+ pub fn printf(self: *Context, comptime format: []const u8, args: anytype) []const u8 {
const allocator = self.getAlloc();
const text = std.fmt.allocPrint(allocator, format, args) catch @panic("OOM");
return text;
@@ -223,7 +215,7 @@ pub const ZxContext = struct {
/// Create an attribute with type-aware value handling
/// Returns null for values that should omit the attribute (false booleans, null optionals)
- pub fn attr(self: *ZxContext, comptime name: []const u8, val: anytype) ?Element.Attribute {
+ pub fn attr(self: *Context, comptime name: []const u8, val: anytype) ?Element.Attribute {
const T = @TypeOf(val);
if (comptime isStatePointer(T)) {
@@ -314,13 +306,13 @@ pub const ZxContext = struct {
};
}
- pub fn attrf(self: *ZxContext, comptime name: []const u8, comptime format: []const u8, args: anytype) ?Element.Attribute {
+ pub fn attrf(self: *Context, comptime name: []const u8, comptime format: []const u8, args: anytype) ?Element.Attribute {
const allocator = self.getAlloc();
const text = std.fmt.allocPrint(allocator, format, args) catch @panic("OOM");
return self.attr(name, text);
}
- pub fn attrv(self: *ZxContext, val: anytype) []const u8 {
+ pub fn attrv(self: *Context, val: anytype) []const u8 {
const attrkv = self.attr("f", val);
if (attrkv) |a| {
return a.value orelse "";
@@ -328,14 +320,14 @@ pub const ZxContext = struct {
return "";
}
- pub fn propf(self: *ZxContext, comptime format: []const u8, args: anytype) []const u8 {
+ pub fn propf(self: *Context, comptime format: []const u8, args: anytype) []const u8 {
const allocator = self.getAlloc();
return std.fmt.allocPrint(allocator, format, args) catch @panic("OOM");
}
pub const propv = attrv;
/// Filter and collect non-null attributes into a slice
- pub fn attrs(self: *ZxContext, inputs: anytype) []const Element.Attribute {
+ pub fn attrs(self: *Context, inputs: anytype) []const Element.Attribute {
const allocator = self.getAlloc();
const InputType = @TypeOf(inputs);
const input_info = @typeInfo(InputType);
@@ -376,7 +368,7 @@ pub const ZxContext = struct {
/// Spread a struct's fields as attributes
/// Takes a struct and returns a slice of attributes for each field
- pub fn attrSpr(self: *ZxContext, props: anytype) []const ?Element.Attribute {
+ pub fn attrSpr(self: *Context, props: anytype) []const ?Element.Attribute {
const allocator = self.getAlloc();
const T = @TypeOf(props);
const type_info = @typeInfo(T);
@@ -400,7 +392,7 @@ pub const ZxContext = struct {
/// Merge two structs for component props spreading
/// Later fields override earlier ones
- pub fn propsM(_: *ZxContext, base: anytype, overrides: anytype) prp.MergedPropsType(@TypeOf(base), @TypeOf(overrides)) {
+ pub fn propsM(_: *Context, base: anytype, overrides: anytype) prp.MergedPropsType(@TypeOf(base), @TypeOf(overrides)) {
const BaseType = @TypeOf(base);
const OverrideType = @TypeOf(overrides);
const ResultType = prp.MergedPropsType(BaseType, OverrideType);
@@ -433,7 +425,7 @@ pub const ZxContext = struct {
/// - ?Element.Attribute (single attribute from attr())
/// - []const ?Element.Attribute (slice from attrSpr())
/// Later attributes with the same name override earlier ones (like JSX)
- pub fn attrsM(self: *ZxContext, inputs: anytype) []const Element.Attribute {
+ pub fn attrsM(self: *Context, inputs: anytype) []const Element.Attribute {
const allocator = self.getAlloc();
const InputType = @TypeOf(inputs);
const input_info = @typeInfo(InputType);
@@ -519,7 +511,7 @@ pub const ZxContext = struct {
return result;
}
- pub fn cmp(self: *ZxContext, comptime func: anytype, options: ZxOptions, props: anytype) Component {
+ pub fn cmp(self: *Context, comptime func: anytype, options: Options, props: anytype) Component {
const allocator = self.getAlloc();
const FuncInfo = @typeInfo(@TypeOf(func));
@@ -600,7 +592,7 @@ pub const ZxContext = struct {
}
/// Allocates a Component and returns a pointer to it (used for @fallback)
- pub fn ptr(self: *ZxContext, component: Component) *const Component {
+ pub fn ptr(self: *Context, component: Component) *const Component {
const allocator = self.getAlloc();
const allocated = allocator.create(Component) catch @panic("OOM");
allocated.* = component;
@@ -609,7 +601,7 @@ pub const ZxContext = struct {
/// Creates a React client-side rendered component.
/// Uses JSON serialization for props to match React's expected format.
- pub fn client(self: *ZxContext, options: ClientComponentOptions, props: anytype) Component {
+ pub fn client(self: *Context, options: ClientComponentOptions, props: anytype) Component {
const allocator = self.getAlloc();
const Props = @TypeOf(props);
diff --git a/test/core/style.zig b/test/core/style.zig
index de2cb984..757d00c1 100644
--- a/test/core/style.zig
+++ b/test/core/style.zig
@@ -30,7 +30,7 @@ test "in Component" {
defer arena.deinit();
const arena_allocator = arena.allocator();
- var ctx = zx.allocInit(arena_allocator);
+ var ctx = zx.x.allocInit(arena_allocator);
const style: S = .{
.color = .hex(0x0000ff),
diff --git a/test/data/attribute/builtin.zig b/test/data/attribute/builtin.zig
index 815ba908..c951aacf 100644
--- a/test/data/attribute/builtin.zig
+++ b/test/data/attribute/builtin.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const a = allocator;
- var _zx = @import("zx").allocInit(a);
+ var _zx = @import("zx").x.allocInit(a);
return _zx.ele(
.section,
.{
@@ -22,7 +22,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
}
fn ArgToBuiltin(arena: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(arena);
+ var _zx = @import("zx").x.allocInit(arena);
return _zx.ele(
.section,
.{
@@ -34,7 +34,7 @@ fn ArgToBuiltin(arena: zx.Allocator) zx.Component {
const Props = struct { c: zx.Allocator };
fn StructToBuiltin(a: zx.Allocator) zx.Component {
const props = Props{ .c = a };
- var _zx = @import("zx").allocInit(props.c);
+ var _zx = @import("zx").x.allocInit(props.c);
return _zx.ele(
.section,
.{
diff --git a/test/data/attribute/builtin_escaping.zig b/test/data/attribute/builtin_escaping.zig
index 716ccc58..30fb9330 100644
--- a/test/data/attribute/builtin_escaping.zig
+++ b/test/data/attribute/builtin_escaping.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.section,
.{
diff --git a/test/data/attribute/component.zig b/test/data/attribute/component.zig
index a2b0b6a7..d027329f 100644
--- a/test/data/attribute/component.zig
+++ b/test/data/attribute/component.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const hello_child = _zx_ele_blk_0: {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
break :_zx_ele_blk_0 _zx.ele(
.div,
.{
@@ -11,7 +11,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
},
);
};
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.section,
.{
@@ -42,7 +42,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
// Note: Not providing allocator here will use the default allocator (std.heap.page_allocator) and will have performance penalty
// Only use this when you need to create a component that doesn't need to allocate memory, like a complete static element.
const hello_child_outside = _zx_ele_blk_1: {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
break :_zx_ele_blk_1 _zx.ele(
.div,
.{
@@ -55,7 +55,7 @@ const hello_child_outside = _zx_ele_blk_1: {
const Props = struct { children: zx.Component };
pub fn ChildComponent(allocator: zx.Allocator, props: Props) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.div,
.{
diff --git a/test/data/attribute/dynamic.zig b/test/data/attribute/dynamic.zig
index 16e8ab3b..cf22f5d2 100644
--- a/test/data/attribute/dynamic.zig
+++ b/test/data/attribute/dynamic.zig
@@ -3,7 +3,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const is_active = true;
const id = "main-content";
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/attribute/event_handler.zig b/test/data/attribute/event_handler.zig
index d56e88b0..984e100f 100644
--- a/test/data/attribute/event_handler.zig
+++ b/test/data/attribute/event_handler.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.fragment,
.{
diff --git a/test/data/attribute/multiline.zig b/test/data/attribute/multiline.zig
new file mode 100644
index 00000000..730807fa
--- /dev/null
+++ b/test/data/attribute/multiline.zig
@@ -0,0 +1,58 @@
+pub fn Page(allocator: zx.Allocator) zx.Component {
+ const class_name = "container";
+ const is_active = true;
+
+ var _zx = @import("zx").x.allocInit(allocator);
+ return _zx.ele(
+ .div,
+ .{
+ .allocator = allocator,
+ .children = &.{
+ _zx.ele(
+ .section,
+ .{
+ .attributes = _zx.attrs(.{
+ _zx.attr("class", class_name),
+ _zx.attr("id", "main"),
+ _zx.attr("data-active", is_active),
+ }),
+ .children = &.{
+ _zx.ele(
+ .p,
+ .{
+ .children = &.{
+ _zx.txt("Multiline attributes"),
+ },
+ },
+ ),
+ },
+ },
+ ),
+ _zx.ele(
+ .input,
+ .{
+ .attributes = _zx.attrs(.{
+ _zx.attr("type", "text"),
+ _zx.attr("class", "input"),
+ _zx.attr("placeholder", "Enter text"),
+ }),
+ },
+ ),
+ _zx.ele(
+ .button,
+ .{
+ .attributes = _zx.attrs(.{
+ _zx.attr("class", "btn"),
+ _zx.attr("id", "submit"),
+ }),
+ .children = &.{
+ _zx.txt("Submit"),
+ },
+ },
+ ),
+ },
+ },
+ );
+}
+
+const zx = @import("zx");
diff --git a/test/data/attribute/multiline_normalize.zig b/test/data/attribute/multiline_normalize.zig
new file mode 100644
index 00000000..7463f9fd
--- /dev/null
+++ b/test/data/attribute/multiline_normalize.zig
@@ -0,0 +1,45 @@
+pub fn Page(allocator: zx.Allocator) zx.Component {
+ const class_name = "container";
+
+ var _zx = @import("zx").x.allocInit(allocator);
+ return _zx.ele(
+ .div,
+ .{
+ .allocator = allocator,
+ .children = &.{
+ _zx.ele(
+ .section,
+ .{
+ .attributes = _zx.attrs(.{
+ _zx.attr("class", class_name),
+ _zx.attr("id", "main"),
+ _zx.attr("data-active", "true"),
+ }),
+ .children = &.{
+ _zx.ele(
+ .p,
+ .{
+ .children = &.{
+ _zx.txt("Messy indentation"),
+ },
+ },
+ ),
+ },
+ },
+ ),
+ _zx.ele(
+ .input,
+ .{
+ .attributes = _zx.attrs(.{
+ _zx.attr("type", "text"),
+ _zx.attr("class", "input"),
+ _zx.attr("placeholder", "Enter text"),
+ }),
+ },
+ ),
+ },
+ },
+ );
+}
+
+const zx = @import("zx");
diff --git a/test/data/attribute/multiline_normalize_out.zig b/test/data/attribute/multiline_normalize_out.zig
new file mode 100644
index 00000000..7463f9fd
--- /dev/null
+++ b/test/data/attribute/multiline_normalize_out.zig
@@ -0,0 +1,45 @@
+pub fn Page(allocator: zx.Allocator) zx.Component {
+ const class_name = "container";
+
+ var _zx = @import("zx").x.allocInit(allocator);
+ return _zx.ele(
+ .div,
+ .{
+ .allocator = allocator,
+ .children = &.{
+ _zx.ele(
+ .section,
+ .{
+ .attributes = _zx.attrs(.{
+ _zx.attr("class", class_name),
+ _zx.attr("id", "main"),
+ _zx.attr("data-active", "true"),
+ }),
+ .children = &.{
+ _zx.ele(
+ .p,
+ .{
+ .children = &.{
+ _zx.txt("Messy indentation"),
+ },
+ },
+ ),
+ },
+ },
+ ),
+ _zx.ele(
+ .input,
+ .{
+ .attributes = _zx.attrs(.{
+ _zx.attr("type", "text"),
+ _zx.attr("class", "input"),
+ _zx.attr("placeholder", "Enter text"),
+ }),
+ },
+ ),
+ },
+ },
+ );
+}
+
+const zx = @import("zx");
diff --git a/test/data/attribute/shorthand.zig b/test/data/attribute/shorthand.zig
index 63c98bce..8322b811 100644
--- a/test/data/attribute/shorthand.zig
+++ b/test/data/attribute/shorthand.zig
@@ -3,7 +3,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const value: i32 = 42;
const class = "b-1 bold";
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.form,
.{
diff --git a/test/data/attribute/spread.zig b/test/data/attribute/spread.zig
index 09ab2d85..611238f8 100644
--- a/test/data/attribute/spread.zig
+++ b/test/data/attribute/spread.zig
@@ -9,7 +9,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
.value = "test@example.com",
};
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.form,
.{
@@ -35,7 +35,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const InputProps = struct { value: []const u8, name: []const u8, extra: []const u8 = "" };
fn Input(ctx: *zx.ComponentCtx(InputProps)) zx.Component {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
diff --git a/test/data/attribute/types.zig b/test/data/attribute/types.zig
index 36339c4d..19429abb 100644
--- a/test/data/attribute/types.zig
+++ b/test/data/attribute/types.zig
@@ -9,7 +9,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const optional_null: ?[]const u8 = null;
const enum_val = InputType.text;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.form,
.{
diff --git a/test/data/component/basic.zig b/test/data/component/basic.zig
index ef534292..f2780565 100644
--- a/test/data/component/basic.zig
+++ b/test/data/component/basic.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -17,7 +17,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const ButtonProps = struct { title: []const u8 };
pub fn Button(allocator: zx.Allocator, props: ButtonProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.button,
.{
diff --git a/test/data/component/caching.zig b/test/data/component/caching.zig
index 131d2a35..83138ae8 100644
--- a/test/data/component/caching.zig
+++ b/test/data/component/caching.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -22,7 +22,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const ButtonProps = struct { title: []const u8 };
pub fn Button(allocator: zx.Allocator, props: ButtonProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.button,
.{
diff --git a/test/data/component/children_only.zig b/test/data/component/children_only.zig
index 698908c5..95880a51 100644
--- a/test/data/component/children_only.zig
+++ b/test/data/component/children_only.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -48,7 +48,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const WrapperProps = struct { children: zx.Component };
fn Wrapper(allocator: zx.Allocator, props: WrapperProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.div,
.{
@@ -65,7 +65,7 @@ fn Wrapper(allocator: zx.Allocator, props: WrapperProps) zx.Component {
const ContainerProps = struct { children: zx.Component };
fn Container(allocator: zx.Allocator, props: ContainerProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.section,
.{
diff --git a/test/data/component/contexted.zig b/test/data/component/contexted.zig
index f97d84c7..d3762622 100644
--- a/test/data/component/contexted.zig
+++ b/test/data/component/contexted.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -40,7 +40,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
/// Component using ComponentContext (void props, children only)
pub fn Wrapper(ctx: *zx.ComponentContext) zx.Component {
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.div,
.{
@@ -57,7 +57,7 @@ pub fn Wrapper(ctx: *zx.ComponentContext) zx.Component {
/// Another component using ComponentContext
fn Card(ctx: *zx.ComponentContext) zx.Component {
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.article,
.{
diff --git a/test/data/component/contexted_props.zig b/test/data/component/contexted_props.zig
index 65c79359..cec2a27c 100644
--- a/test/data/component/contexted_props.zig
+++ b/test/data/component/contexted_props.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -37,7 +37,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
/// Component using ComponentCtx with props (no children)
const ButtonProps = struct { title: []const u8 };
pub fn Button(ctx: *zx.ComponentCtx(ButtonProps)) zx.Component {
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.button,
.{
@@ -55,7 +55,7 @@ pub fn Button(ctx: *zx.ComponentCtx(ButtonProps)) zx.Component {
/// Component with multiple props
const AlertProps = struct { message: []const u8, level: []const u8 };
fn Alert(ctx: *zx.ComponentCtx(AlertProps)) zx.Component {
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.div,
.{
@@ -74,7 +74,7 @@ fn Alert(ctx: *zx.ComponentCtx(AlertProps)) zx.Component {
/// Component with props AND children
const PanelProps = struct { title: []const u8 };
fn Panel(ctx: *zx.ComponentCtx(PanelProps)) zx.Component {
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.section,
.{
diff --git a/test/data/component/csr_react_multiple.zig b/test/data/component/csr_react_multiple.zig
index 5cef3ff5..995fef8c 100644
--- a/test/data/component/csr_react_multiple.zig
+++ b/test/data/component/csr_react_multiple.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const max_count = 10;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/component/csr_zig.zig b/test/data/component/csr_zig.zig
index 75f1acb9..72bf4f1e 100644
--- a/test/data/component/csr_zig.zig
+++ b/test/data/component/csr_zig.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -26,7 +26,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
}
pub fn CounterComponent(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.button,
.{
diff --git a/test/data/component/csr_zig_props.zig b/test/data/component/csr_zig_props.zig
index f712fb6e..da1c136f 100644
--- a/test/data/component/csr_zig_props.zig
+++ b/test/data/component/csr_zig_props.zig
@@ -1,6 +1,6 @@
/// Test: CSR Zig component with props passed from server to client
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -28,7 +28,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const CounterProps = struct { initial: i32 = 0, label: []const u8 = "Count" };
pub fn Counter(ctx: *zx.ComponentCtx(CounterProps)) zx.Component {
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.div,
.{
diff --git a/test/data/component/error_component.zig b/test/data/component/error_component.zig
index 8fcfb0bf..2e7f7989 100644
--- a/test/data/component/error_component.zig
+++ b/test/data/component/error_component.zig
@@ -1,6 +1,6 @@
/// Test: Components with error union return type (!Component)
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -25,7 +25,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const FallibleProps = struct { success: bool };
pub fn Fallible(allocator: zx.Allocator, props: FallibleProps) !zx.Component {
if (!props.success) return error.TestError;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.div,
.{
@@ -40,7 +40,7 @@ pub fn Fallible(allocator: zx.Allocator, props: FallibleProps) !zx.Component {
/// Error union with ComponentCtx signature
pub fn FallibleCtx(ctx: *zx.ComponentCtx(FallibleProps)) !zx.Component {
if (!ctx.props.success) return error.TestError;
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.div,
.{
diff --git a/test/data/component/import.zig b/test/data/component/import.zig
index 8a6cc468..e68dab8e 100644
--- a/test/data/component/import.zig
+++ b/test/data/component/import.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: z.Allocator) z.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/component/multiple.zig b/test/data/component/multiple.zig
index 51155015..d71e19d4 100644
--- a/test/data/component/multiple.zig
+++ b/test/data/component/multiple.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -37,7 +37,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const ButtonProps = struct { title: []const u8 };
fn Button(allocator: zx.Allocator, props: ButtonProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.button,
.{
@@ -51,7 +51,7 @@ fn Button(allocator: zx.Allocator, props: ButtonProps) zx.Component {
const AsyncScoreProps = struct { index: u64, label: []const u8 };
fn AsyncScore(allocator: zx.Allocator, props: AsyncScoreProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.span,
.{
diff --git a/test/data/component/namespace.zig b/test/data/component/namespace.zig
index b798d388..d34b6d33 100644
--- a/test/data/component/namespace.zig
+++ b/test/data/component/namespace.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -18,7 +18,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const components = struct {
const ButtonProps = struct { title: []const u8 };
pub fn Button(allocator: zx.Allocator, props: ButtonProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.button,
.{
diff --git a/test/data/component/nested.zig b/test/data/component/nested.zig
index 3e91ba8f..32a3e3f2 100644
--- a/test/data/component/nested.zig
+++ b/test/data/component/nested.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -23,7 +23,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const CardProps = struct { title: []const u8, children: zx.Component };
fn Card(allocator: zx.Allocator, props: CardProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.div,
.{
@@ -61,7 +61,7 @@ fn Card(allocator: zx.Allocator, props: CardProps) zx.Component {
const ButtonProps = struct { label: []const u8 };
fn Button(allocator: zx.Allocator, props: ButtonProps) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.button,
.{
diff --git a/test/data/component/optional.zig b/test/data/component/optional.zig
index a4fc4607..28dd141e 100644
--- a/test/data/component/optional.zig
+++ b/test/data/component/optional.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/component/optional_error.zig b/test/data/component/optional_error.zig
index 903f16be..1711f84e 100644
--- a/test/data/component/optional_error.zig
+++ b/test/data/component/optional_error.zig
@@ -1,6 +1,6 @@
/// Test: Components with error union of optional return type (!?Component)
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -25,7 +25,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const MaybeProps = struct { show: bool };
pub fn MaybeContent(ctx: *zx.ComponentCtx(MaybeProps)) !?zx.Component {
if (!ctx.props.show) return null;
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.div,
.{
diff --git a/test/data/component/react.zig b/test/data/component/react.zig
index 4c9dbbee..742306a6 100644
--- a/test/data/component/react.zig
+++ b/test/data/component/react.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const max_count = 10;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/component/root_cmp.zig b/test/data/component/root_cmp.zig
index daa7659a..dc933fbb 100644
--- a/test/data/component/root_cmp.zig
+++ b/test/data/component/root_cmp.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.cmp(
Button,
.{ .name = "Button" },
@@ -8,7 +8,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
}
pub fn Button(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.button,
.{
diff --git a/test/data/control_flow/for.zig b/test/data/control_flow/for.zig
index 1c433eda..08fd6d71 100644
--- a/test/data/control_flow/for.zig
+++ b/test/data/control_flow/for.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const user_names = [_][]const u8{ "John", "Jane", "Jim", "Jill" };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -26,7 +26,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
}
pub fn StructCapture(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -54,7 +54,7 @@ pub fn StructCapture(allocator: zx.Allocator) zx.Component {
}
pub fn StructExtraCapture(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -85,7 +85,7 @@ pub fn StructExtraCapture(allocator: zx.Allocator) zx.Component {
pub fn StructComplexParam(allocator: zx.Allocator) zx.Component {
const data = .{ .users = users };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -139,7 +139,7 @@ fn getUsers() [users.len]User {
}
pub fn StructCaptureToComponent(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
@@ -170,7 +170,7 @@ const users = [_]User{
};
fn UserComponent(allocator: zx.Allocator, props: User) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.p,
.{
diff --git a/test/data/control_flow/for_block.zig b/test/data/control_flow/for_block.zig
index bc9af40c..518f2dae 100644
--- a/test/data/control_flow/for_block.zig
+++ b/test/data/control_flow/for_block.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const chars = "ABC";
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/for_for.zig b/test/data/control_flow/for_for.zig
index 7ece77f4..b6e1742f 100644
--- a/test/data/control_flow/for_for.zig
+++ b/test/data/control_flow/for_for.zig
@@ -3,7 +3,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
.{ .name = "Team A", .members = &[_][]const u8{ "John", "Jane" } },
.{ .name = "Team B", .members = &[_][]const u8{ "Jim", "Jill" } },
};
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/for_if.zig b/test/data/control_flow/for_if.zig
index ff437c90..a84cbcbf 100644
--- a/test/data/control_flow/for_if.zig
+++ b/test/data/control_flow/for_if.zig
@@ -4,7 +4,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
.{ .name = "Jane", .is_active = false },
.{ .name = "Jim", .is_active = true },
};
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/for_range.zig b/test/data/control_flow/for_range.zig
index 8e6fe91a..e53819c8 100644
--- a/test/data/control_flow/for_range.zig
+++ b/test/data/control_flow/for_range.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/for_switch.zig b/test/data/control_flow/for_switch.zig
index 013acc68..533025e3 100644
--- a/test/data/control_flow/for_switch.zig
+++ b/test/data/control_flow/for_switch.zig
@@ -4,7 +4,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
.{ .name = "Jane", .role = .member },
.{ .name = "Jim", .role = .guest },
};
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/for_while.zig b/test/data/control_flow/for_while.zig
index 882a62cb..e758c1be 100644
--- a/test/data/control_flow/for_while.zig
+++ b/test/data/control_flow/for_while.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const groups = [_][]const u8{ "A", "B" };
var j: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if.zig b/test/data/control_flow/if.zig
index 8ce971be..67fab32b 100644
--- a/test/data/control_flow/if.zig
+++ b/test/data/control_flow/if.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_block.zig b/test/data/control_flow/if_block.zig
index 0e4c603e..f4b53aff 100644
--- a/test/data/control_flow/if_block.zig
+++ b/test/data/control_flow/if_block.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const is_logged_in = false;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_capture.zig b/test/data/control_flow/if_capture.zig
index a3e997c4..22d5e4b1 100644
--- a/test/data/control_flow/if_capture.zig
+++ b/test/data/control_flow/if_capture.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const is_logged_in = false;
const user_name = if (is_logged_in) "zx" else null;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_else_if.zig b/test/data/control_flow/if_else_if.zig
index c1dd062f..0048deec 100644
--- a/test/data/control_flow/if_else_if.zig
+++ b/test/data/control_flow/if_else_if.zig
@@ -6,7 +6,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const is_trial = false;
const is_guest = false;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_error.zig b/test/data/control_flow/if_error.zig
index b760fb95..13c52bb2 100644
--- a/test/data/control_flow/if_error.zig
+++ b/test/data/control_flow/if_error.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const user = "John Doe";
const user_empty = "";
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_for.zig b/test/data/control_flow/if_for.zig
index 6af8a777..42e6de10 100644
--- a/test/data/control_flow/if_for.zig
+++ b/test/data/control_flow/if_for.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const show_users = true;
const user_names = [_][]const u8{ "John", "Jane", "Jim", "Jill" };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_for_if.zig b/test/data/control_flow/if_for_if.zig
index 3245f41f..f4dfe5bb 100644
--- a/test/data/control_flow/if_for_if.zig
+++ b/test/data/control_flow/if_for_if.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const show_list = true;
const items = [_][]const u8{ "Apple", "Banana", "Cherry" };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_if.zig b/test/data/control_flow/if_if.zig
index 3af70e1f..4c27ca63 100644
--- a/test/data/control_flow/if_if.zig
+++ b/test/data/control_flow/if_if.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const is_logged_in = true;
const is_premium = false;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_if_only.zig b/test/data/control_flow/if_if_only.zig
index 49bc2f31..e44e078f 100644
--- a/test/data/control_flow/if_if_only.zig
+++ b/test/data/control_flow/if_if_only.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const is_logged_in = true;
const is_premium = true;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_if_only_block.zig b/test/data/control_flow/if_if_only_block.zig
index 50495486..2016ac5b 100644
--- a/test/data/control_flow/if_if_only_block.zig
+++ b/test/data/control_flow/if_if_only_block.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const is_logged_in = true;
const is_premium = true;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_only.zig b/test/data/control_flow/if_only.zig
index f0e0d99b..2d29d9c1 100644
--- a/test/data/control_flow/if_only.zig
+++ b/test/data/control_flow/if_only.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const is_logged_in = false;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_only_block.zig b/test/data/control_flow/if_only_block.zig
index dc28b121..25986463 100644
--- a/test/data/control_flow/if_only_block.zig
+++ b/test/data/control_flow/if_only_block.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const is_logged_in = true;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_switch.zig b/test/data/control_flow/if_switch.zig
index c2088783..e237e3a2 100644
--- a/test/data/control_flow/if_switch.zig
+++ b/test/data/control_flow/if_switch.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const show_user_type = true;
const user_type: UserType = .admin;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_while.zig b/test/data/control_flow/if_while.zig
index 37f547fd..5be7d48e 100644
--- a/test/data/control_flow/if_while.zig
+++ b/test/data/control_flow/if_while.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const show_list = true;
var i: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/if_while_if.zig b/test/data/control_flow/if_while_if.zig
index 7c708508..9f4973cb 100644
--- a/test/data/control_flow/if_while_if.zig
+++ b/test/data/control_flow/if_while_if.zig
@@ -3,7 +3,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const items = [_][]const u8{ "Apple", "Banana", "Cherry" };
var i: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch.zig b/test/data/control_flow/switch.zig
index aa663b12..8934bf8d 100644
--- a/test/data/control_flow/switch.zig
+++ b/test/data/control_flow/switch.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const user_type: UserType = .admin;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch_block.zig b/test/data/control_flow/switch_block.zig
index 7e1c363b..59ca443f 100644
--- a/test/data/control_flow/switch_block.zig
+++ b/test/data/control_flow/switch_block.zig
@@ -1,6 +1,6 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const user_type: UserType = .admin;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch_capture.zig b/test/data/control_flow/switch_capture.zig
index 8e90bf0d..07cd0fbb 100644
--- a/test/data/control_flow/switch_capture.zig
+++ b/test/data/control_flow/switch_capture.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const admin_user: User = .{ .admin = .{ .level = 5 } };
const member_user: User = .{ .member = .{ .points = 150 } };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch_caseranges.zig b/test/data/control_flow/switch_caseranges.zig
index d35a52c2..5c6a1986 100644
--- a/test/data/control_flow/switch_caseranges.zig
+++ b/test/data/control_flow/switch_caseranges.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const chars = "abcdefg";
const char = chars[0];
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch_for.zig b/test/data/control_flow/switch_for.zig
index baa25f7a..ffa97b47 100644
--- a/test/data/control_flow/switch_for.zig
+++ b/test/data/control_flow/switch_for.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const user_type: UserType = .admin;
const admin_users = [_][]const u8{ "John", "Jane" };
const member_users = [_][]const u8{ "Jim", "Jill" };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch_if.zig b/test/data/control_flow/switch_if.zig
index 9e4b079e..6dfd2cae 100644
--- a/test/data/control_flow/switch_if.zig
+++ b/test/data/control_flow/switch_if.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const user_type: UserType = .admin;
const is_active = true;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch_multicaseval.zig b/test/data/control_flow/switch_multicaseval.zig
index fce6dae5..ae9613f8 100644
--- a/test/data/control_flow/switch_multicaseval.zig
+++ b/test/data/control_flow/switch_multicaseval.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const u: User = .{ .member = .{ .points = 150 } };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch_switch.zig b/test/data/control_flow/switch_switch.zig
index 808399c1..e5265177 100644
--- a/test/data/control_flow/switch_switch.zig
+++ b/test/data/control_flow/switch_switch.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const user_type: UserType = .admin;
const status: Status = .inactive;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/switch_while.zig b/test/data/control_flow/switch_while.zig
index fe567b02..d695fb81 100644
--- a/test/data/control_flow/switch_while.zig
+++ b/test/data/control_flow/switch_while.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const mode: Mode = .repeat;
var i: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while.zig b/test/data/control_flow/while.zig
index fb20c578..a8c380b9 100644
--- a/test/data/control_flow/while.zig
+++ b/test/data/control_flow/while.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
var i: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while_block.zig b/test/data/control_flow/while_block.zig
index 1a689e29..745d2a56 100644
--- a/test/data/control_flow/while_block.zig
+++ b/test/data/control_flow/while_block.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
var i: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while_capture.zig b/test/data/control_flow/while_capture.zig
index 8dfcaa00..b25c9b2c 100644
--- a/test/data/control_flow/while_capture.zig
+++ b/test/data/control_flow/while_capture.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
var iter = getIterator();
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while_else.zig b/test/data/control_flow/while_else.zig
index 601ebb60..f45c170b 100644
--- a/test/data/control_flow/while_else.zig
+++ b/test/data/control_flow/while_else.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
var iter = getIterator();
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while_error.zig b/test/data/control_flow/while_error.zig
index 90814ae6..b874acfd 100644
--- a/test/data/control_flow/while_error.zig
+++ b/test/data/control_flow/while_error.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
var iter = getIterator();
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while_for.zig b/test/data/control_flow/while_for.zig
index 7a9d375e..5caf7d54 100644
--- a/test/data/control_flow/while_for.zig
+++ b/test/data/control_flow/while_for.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
var i: usize = 0;
const items = [_][]const u8{ "a", "b" };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while_if.zig b/test/data/control_flow/while_if.zig
index c6fe1e1e..79689232 100644
--- a/test/data/control_flow/while_if.zig
+++ b/test/data/control_flow/while_if.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
var i: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while_switch.zig b/test/data/control_flow/while_switch.zig
index 6ecd7210..77848c72 100644
--- a/test/data/control_flow/while_switch.zig
+++ b/test/data/control_flow/while_switch.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
var i: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/control_flow/while_while.zig b/test/data/control_flow/while_while.zig
index c28e061a..af1dbc60 100644
--- a/test/data/control_flow/while_while.zig
+++ b/test/data/control_flow/while_while.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
var i: usize = 0;
var j: usize = 0;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/element/empty.zig b/test/data/element/empty.zig
index 2fd93575..18f50143 100644
--- a/test/data/element/empty.zig
+++ b/test/data/element/empty.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/element/fragment.zig b/test/data/element/fragment.zig
index a3c82c72..87244318 100644
--- a/test/data/element/fragment.zig
+++ b/test/data/element/fragment.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/element/fragment_root.zig b/test/data/element/fragment_root.zig
index 9dd1ca4a..d36d7040 100644
--- a/test/data/element/fragment_root.zig
+++ b/test/data/element/fragment_root.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.fragment,
.{
@@ -16,7 +16,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
}
fn FragmentComponent(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.fragment,
.{
diff --git a/test/data/element/nested.zig b/test/data/element/nested.zig
index 7615637d..7cd6d2b1 100644
--- a/test/data/element/nested.zig
+++ b/test/data/element/nested.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/element/void.zig b/test/data/element/void.zig
index 39cb1533..d5eddde1 100644
--- a/test/data/element/void.zig
+++ b/test/data/element/void.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/escaping/comments.zig b/test/data/escaping/comments.zig
index 1122f2b8..1dbad45a 100644
--- a/test/data/escaping/comments.zig
+++ b/test/data/escaping/comments.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.section,
.{
@@ -13,7 +13,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
}
pub fn Comments(_: zx.ComponentContext) zx.Component {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
@@ -30,7 +30,7 @@ pub fn Comments(_: zx.ComponentContext) zx.Component {
}
pub fn EmptyComments(_: zx.ComponentContext) zx.Element {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
@@ -49,7 +49,7 @@ pub fn EmptyComments(_: zx.ComponentContext) zx.Element {
}
pub fn CommentsWithSpecialChars(_: zx.ComponentContext) zx.Element {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
@@ -69,7 +69,7 @@ pub fn CommentsWithSpecialChars(_: zx.ComponentContext) zx.Element {
pub fn CommentsWithExpressions(_: zx.ComponentContext) zx.Element {
const value = "test";
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
@@ -91,7 +91,7 @@ pub fn CommentsWithExpressions(_: zx.ComponentContext) zx.Element {
}
pub fn NestedComments(_: zx.ComponentContext) zx.Element {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
@@ -124,7 +124,7 @@ pub fn NestedComments(_: zx.ComponentContext) zx.Element {
}
pub fn CommentsWithAttributes(_: zx.ComponentContext) zx.Element {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
@@ -143,7 +143,7 @@ pub fn CommentsWithAttributes(_: zx.ComponentContext) zx.Element {
}
pub fn MixedCommentsAndContent(_: zx.ComponentContext) zx.Element {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.ul,
.{
@@ -178,7 +178,7 @@ pub fn MixedCommentsAndContent(_: zx.ComponentContext) zx.Element {
}
pub fn CommentsWithZigCode(_: zx.ComponentContext) zx.Element {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
@@ -197,7 +197,7 @@ pub fn CommentsWithZigCode(_: zx.ComponentContext) zx.Element {
}
pub fn CommentsOnlyComponent(_: zx.ComponentContext) zx.Element {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
@@ -207,7 +207,7 @@ pub fn CommentsOnlyComponent(_: zx.ComponentContext) zx.Element {
}
pub fn CommentsBetweenSiblings(_: zx.ComponentContext) zx.Element {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
diff --git a/test/data/escaping/pre.zig b/test/data/escaping/pre.zig
index 15a4567c..5f7590fd 100644
--- a/test/data/escaping/pre.zig
+++ b/test/data/escaping/pre.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.section,
.{
diff --git a/test/data/escaping/quotes.zig b/test/data/escaping/quotes.zig
index 4579b4a5..e9125794 100644
--- a/test/data/escaping/quotes.zig
+++ b/test/data/escaping/quotes.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.div,
.{
diff --git a/test/data/expression/component.zig b/test/data/expression/component.zig
index 2ec1bdbe..693432b2 100644
--- a/test/data/expression/component.zig
+++ b/test/data/expression/component.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const greeting = zx.Component{ .text = "Hello!" };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.section,
.{
diff --git a/test/data/expression/format.zig b/test/data/expression/format.zig
index ea7f7473..ba997972 100644
--- a/test/data/expression/format.zig
+++ b/test/data/expression/format.zig
@@ -15,7 +15,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
// persons[0] = person;
// persons[1] = person;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.section,
.{
diff --git a/test/data/expression/function_call.zig b/test/data/expression/function_call.zig
index 3f3a8dfe..5153e0eb 100644
--- a/test/data/expression/function_call.zig
+++ b/test/data/expression/function_call.zig
@@ -1,7 +1,7 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
const items = [_][]const u8{ "apple", "banana", "cherry" };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/expression/mixed.zig b/test/data/expression/mixed.zig
index 15b6f1c6..01ae06f3 100644
--- a/test/data/expression/mixed.zig
+++ b/test/data/expression/mixed.zig
@@ -3,7 +3,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const count = 5;
const item = "apple";
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/expression/multiline_string.zig b/test/data/expression/multiline_string.zig
index b85e831c..bd62451c 100644
--- a/test/data/expression/multiline_string.zig
+++ b/test/data/expression/multiline_string.zig
@@ -1,5 +1,5 @@
pub fn Page(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/expression/optional.zig b/test/data/expression/optional.zig
index 3dc535b2..0f7fe54c 100644
--- a/test/data/expression/optional.zig
+++ b/test/data/expression/optional.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const maybe_name: ?[]const u8 = "Alice";
const no_name: ?[]const u8 = null;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/expression/struct_access.zig b/test/data/expression/struct_access.zig
index 5447f074..5aaaeaad 100644
--- a/test/data/expression/struct_access.zig
+++ b/test/data/expression/struct_access.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const user = User{ .name = "Alice", .age = 25 };
const product = Product{ .title = "Book", .price = 29.99 };
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/expression/template.zig b/test/data/expression/template.zig
index a5abb50b..94620098 100644
--- a/test/data/expression/template.zig
+++ b/test/data/expression/template.zig
@@ -2,7 +2,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const count = 42;
const name = "John";
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.section,
.{
@@ -44,7 +44,7 @@ fn Component(ctx: *zx.ComponentCtx(struct {
text: []const u8,
name: []const u8,
})) zx.Component {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
diff --git a/test/data/expression/text.zig b/test/data/expression/text.zig
index 838a510a..f61d30c4 100644
--- a/test/data/expression/text.zig
+++ b/test/data/expression/text.zig
@@ -3,7 +3,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const html_content = "";
const unsafe_html = "Test";
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.main,
.{
diff --git a/test/data/fmt/inline_spaces.zig b/test/data/fmt/inline_spaces.zig
index a0cf1531..d25bb986 100644
--- a/test/data/fmt/inline_spaces.zig
+++ b/test/data/fmt/inline_spaces.zig
@@ -1,6 +1,6 @@
pub fn Collection(allocator: zx.Allocator, props: anytype) zx.Component {
const cards = props.cards;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.div,
.{
diff --git a/test/data/fmt/inline_spaces_out.zig b/test/data/fmt/inline_spaces_out.zig
index a0cf1531..d25bb986 100644
--- a/test/data/fmt/inline_spaces_out.zig
+++ b/test/data/fmt/inline_spaces_out.zig
@@ -1,6 +1,6 @@
pub fn Collection(allocator: zx.Allocator, props: anytype) zx.Component {
const cards = props.cards;
- var _zx = @import("zx").allocInit(allocator);
+ var _zx = @import("zx").x.allocInit(allocator);
return _zx.ele(
.div,
.{
diff --git a/test/data/fmt/whitespace.zig b/test/data/fmt/whitespace.zig
index 1c0fb2f3..dfe878b8 100644
--- a/test/data/fmt/whitespace.zig
+++ b/test/data/fmt/whitespace.zig
@@ -1,5 +1,5 @@
pub fn FmtWhitespace(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
diff --git a/test/data/fmt/whitespace_out.zig b/test/data/fmt/whitespace_out.zig
index 1c0fb2f3..dfe878b8 100644
--- a/test/data/fmt/whitespace_out.zig
+++ b/test/data/fmt/whitespace_out.zig
@@ -1,5 +1,5 @@
pub fn FmtWhitespace(allocator: zx.Allocator) zx.Component {
- var _zx = @import("zx").init();
+ var _zx = @import("zx").x.init();
return _zx.ele(
.div,
.{
diff --git a/test/data/mdzx/basic.zig b/test/data/mdzx/basic.zig
index 7c9231eb..23d4aab5 100644
--- a/test/data/mdzx/basic.zig
+++ b/test/data/mdzx/basic.zig
@@ -1,5 +1,5 @@
pub fn _zx_md(ctx: *@import("zx").ComponentCtx(struct { children: @import("zx").Component })) @import("zx").Component {
- var _zx = @import("zx").allocInit(ctx.allocator);
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.h1,
.{
diff --git a/test/data/mdzx/page.zig b/test/data/mdzx/page.zig
new file mode 100644
index 00000000..00ad9d8c
--- /dev/null
+++ b/test/data/mdzx/page.zig
@@ -0,0 +1,83 @@
+const zx = @import("zx");
+const std = @import("std");
+const Lightning = @import("site/pages/components/icons.zig").Lightning;
+pub const meta = .{
+ .title = "The Ultimate MDZX Test Suite",
+ .version = "0.1.0",
+ .tags = .{ "test", "markdown", "zig" },
+ .draft = false,
+};
+pub const options: zx.PageOptions = .{};
+
+pub fn _zx_md(ctx: *@import("zx").ComponentCtx(struct { children: @import("zx").Component })) @import("zx").Component {
+ var _zx = @import("zx").x.allocInit(ctx.allocator);
+ return _zx.ele(
+ .div,
+ .{
+ .allocator = ctx.allocator,
+ .children = &.{
+ _zx.cmp(
+ Lightning,
+ .{ .name = "Lightning" },
+ .{ .class = "w-6 h-6 text-yellow-500" },
+ ),
+ _zx.ele(
+ .h1,
+ .{
+ .children = &.{
+ _zx.txt("1. Headers & Formatting"),
+ },
+ },
+ ),
+ _zx.ele(
+ .h1,
+ .{
+ .children = &.{
+ _zx.txt("H1 Header"),
+ },
+ },
+ ),
+ _zx.ele(
+ .h2,
+ .{
+ .children = &.{
+ _zx.txt("H2 Header"),
+ },
+ },
+ ),
+ _zx.ele(
+ .h3,
+ .{
+ .children = &.{
+ _zx.txt("H3 Header"),
+ },
+ },
+ ),
+ _zx.ele(
+ .h4,
+ .{
+ .children = &.{
+ _zx.txt("H4 Header"),
+ },
+ },
+ ),
+ _zx.ele(
+ .h5,
+ .{
+ .children = &.{
+ _zx.txt("H5 Header"),
+ },
+ },
+ ),
+ _zx.ele(
+ .h6,
+ .{
+ .children = &.{
+ _zx.txt("H6 Header"),
+ },
+ },
+ ),
+ },
+ },
+ );
+}
diff --git a/test/data/style/basic.zig b/test/data/style/basic.zig
new file mode 100644
index 00000000..d4bdf400
--- /dev/null
+++ b/test/data/style/basic.zig
@@ -0,0 +1,21 @@
+pub fn Page(allocator: zx.Allocator) zx.Component {
+ const style: zx.Style = .{
+ .display = .flex,
+ .background_color = .hex(0xff0000),
+ };
+ var _zx = @import("zx").x.allocInit(allocator);
+ return _zx.ele(
+ .div,
+ .{
+ .allocator = allocator,
+ .attributes = _zx.attrs(.{
+ _zx.attr("style", style),
+ }),
+ .children = &.{
+ _zx.txt(" Hello"),
+ },
+ },
+ );
+}
+
+const zx = @import("zx");
diff --git a/test/data/style/component.zig b/test/data/style/component.zig
new file mode 100644
index 00000000..425f311d
--- /dev/null
+++ b/test/data/style/component.zig
@@ -0,0 +1,23 @@
+pub fn Page(allocator: zx.Allocator) zx.Component {
+ const style: zx.Style = .{
+ .display = .flex,
+ .flex_direction = .column,
+ .padding_top = .px(10),
+ .width = .px(100),
+ };
+ var _zx = @import("zx").x.allocInit(allocator);
+ return _zx.ele(
+ .div,
+ .{
+ .allocator = allocator,
+ .attributes = _zx.attrs(.{
+ _zx.attr("style", style),
+ }),
+ .children = &.{
+ _zx.txt(" Hello"),
+ },
+ },
+ );
+}
+
+const zx = @import("zx");
diff --git a/test/data/style/inline.zig b/test/data/style/inline.zig
new file mode 100644
index 00000000..ac5e9483
--- /dev/null
+++ b/test/data/style/inline.zig
@@ -0,0 +1,17 @@
+pub fn Page(allocator: zx.Allocator) zx.Component {
+ var _zx = @import("zx").x.allocInit(allocator);
+ return _zx.ele(
+ .div,
+ .{
+ .allocator = allocator,
+ .attributes = _zx.attrs(.{
+ _zx.attr("style", .{ .display = .flex, .padding_top = .px(10), .width = .px(100) }),
+ }),
+ .children = &.{
+ _zx.txt(" Hello"),
+ },
+ },
+ );
+}
+
+const zx = @import("zx");