Skip to content

Commit

Permalink
The previous fix did not work. Added a different one.
Browse files Browse the repository at this point in the history
  • Loading branch information
RussBaz committed Apr 2, 2024
1 parent 68b397f commit bbe324e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Here is an example of the `Reparse` syntax as used in the bundled `Example` proj
If you would like to use it in your own project, firstly, add it to your package dependencies like this:

```swift
.package(url: "https://github.com/RussBaz/experimental-reparse-html.git", from: "0.0.14"),
.package(url: "https://github.com/RussBaz/experimental-reparse-html.git", from: "0.0.15"),
```

Then add the `ReparseRuntime` as a dependency to your target like this:
Expand Down
6 changes: 4 additions & 2 deletions Resources/Pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ <h1>
data-loading-delay
data-loading-disable
hx-vals='{"key": "\(key)"}'
on-click="console.log('?')"
disabled='\(context.count < 6 ? "true" : "false" )'
onclick="console.log('?')"
onfocus="console.log('?');
console.log('This is drastic?');
console.log('too many');"

>
<r-set name="disabled" r-if="!context.isEmpty" />
<r-set name="requried" r-if="!context.isEmpty" />
What's up?
</button>
</main>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/SwiftOutputBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class SwiftOutputBuilder {
let topLine = """
//
// ------------------------------
// reparse version: 0.0.13
// reparse version: 0.0.15
// ------------------------------
// This is an auto-generated file
// ------------------------------
Expand Down
8 changes: 6 additions & 2 deletions Sources/Example/pages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,13 @@ enum Pages {
</p>
""")
attributes = SwiftAttributeStorage.from(attributes: ["class": .string("button", wrapper: .double), "hx-post": .string("/auth/logout?next=/", wrapper: .double), "hx-target": .string("body", wrapper: .double), "hx-vals": .string("{\"key\": \"\(key)\"}", wrapper: .single), "on-click": .string("console.log('?')", wrapper: .double), "onfocus": .string("console.log('?'); console.log('This is drastic?'); console.log('too many');", wrapper: .double), "data-loading-delay": .flag, "data-loading-disable": .flag])
attributes = SwiftAttributeStorage.from(attributes: ["class": .string("button", wrapper: .double), "disabled": .string("""
\(context.count < 6 ? "true" : "false")
""", wrapper: .single), "hx-post": .string("/auth/logout?next=/", wrapper: .double), "hx-target": .string("body", wrapper: .double), "hx-vals": .string("""
{"key": "\(key)"}
""", wrapper: .single), "onclick": .string("console.log('?')", wrapper: .double), "onfocus": .string("console.log('?'); console.log('This is drastic?'); console.log('too many');", wrapper: .double), "data-loading-delay": .flag, "data-loading-disable": .flag])
if !context.isEmpty {
attributes.replace(key: "disabled", with: .flag)
attributes.replace(key: "requried", with: .flag)
previousUnnamedIfTaken = true
} else {
previousUnnamedIfTaken = false
Expand Down
12 changes: 6 additions & 6 deletions Sources/Runtime/SwiftAttributeStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public final class SwiftAttributeStorage {
case let .string(v, wrapper):
switch wrapper {
case .single:
lines.append("\"\(key)\": .string(\"\(v.replacing("\"", with: "\\\""))\", wrapper: .single)")
lines.append("\"\(key)\": .string(\"\"\"\n\(v)\n\"\"\", wrapper: .single)")
case .double:
lines.append("\"\(key)\": .string(\"\(v.replacing("\"", with: "\\\""))\", wrapper: .double)")
lines.append("\"\(key)\": .string(\"\(v)\", wrapper: .double)")
case .none:
lines.append("\"\(key)\": .string(\"\(v.replacing("\"", with: "\\\""))\", wrapper: .none)")
lines.append("\"\(key)\": .string(\"\(v)\", wrapper: .none)")
}
}
}
Expand Down Expand Up @@ -149,11 +149,11 @@ public extension SwiftAttributeStorage.AttributeValue {
case let .string(string, wrapper):
switch wrapper {
case .single:
".string(\"\(string.replacing("\"", with: "\\\""))\", wrapper: .single)"
".string(\"\"\"\n\(string)\n\"\"\", wrapper: .single)"
case .double:
".string(\"\(string.replacing("\"", with: "\\\""))\", wrapper: .double)"
".string(\"\(string)\", wrapper: .double)"
case .none:
".string(\"\(string.replacing("\"", with: "\\\""))\", wrapper: .none)"
".string(\"\(string)\", wrapper: .none)"
}
}
}
Expand Down

0 comments on commit bbe324e

Please sign in to comment.