Swiftui2Lvn (swiftui_2_lvn v0.1.6)

View Source

Transform SwiftUI code into LiveViewNative templates.

This library provides functionality to parse SwiftUI code and convert it into LiveViewNative .heex syntax, making it easier to port existing SwiftUI views to LiveViewNative applications.

Examples

iex> Swiftui2Lvn.convert(~s|Text("Hello World")|)
~s|<Text>Hello World</Text>|

iex> Swiftui2Lvn.convert(~s|VStack(alignment: .leading).font(.title).padding()|)
~s|<VStack style={["font(.title)", "padding()"]} alignment=".leading" />|

Summary

Functions

Converts SwiftUI code to LiveViewNative template syntax.

Converts SwiftUI code to LiveViewNative AST without printing to string.

Functions

convert(swift_code)

Converts SwiftUI code to LiveViewNative template syntax.

Examples

iex> Swiftui2Lvn.convert(~s|Text("Hello")|)
~s|<Text>Hello</Text>|

iex> Swiftui2Lvn.convert(~s|VStack { Text("Hello") }|)
~s|<VStack><Text>Hello</Text></VStack>|

to_ast(swift_code)

Converts SwiftUI code to LiveViewNative AST without printing to string.

This is useful when you need to inspect or modify the AST before converting to the final template.

Examples

iex> Swiftui2Lvn.to_ast(~s|Text("Hello")|)
[%NeexAstNode{tag: "Text", attributes: %{}, children: ["Hello"]}]