liveview-native / live_view_native_stylesheet

MIT License
10 stars 4 forks source link

Add `to_number` #34

Closed NduatiK closed 7 months ago

NduatiK commented 9 months ago

The new #{variable} syntax required for SwiftUI expects a float or integer variable.

To support both, we first attempt to convert the entire expr into an integer, if that fails we try converting it into a float.


If the variable is not a number, we return the original string.

For example if we had the following rule:

"h-" <> height do
  height(#{height})
end

The class h-abc would produce the ast for height("abc") and it would be up to the client to detect the error.

NduatiK commented 7 months ago

Closing in favour of EEx support