Skip to content

Commit

Permalink
Merge pull request #673 from SwiftFiddle/update-sample
Browse files Browse the repository at this point in the history
Update sample code
  • Loading branch information
kishikawakatsumi authored Sep 8, 2023
2 parents 1a49b9e + df312c4 commit ca2bb5b
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 2,555 deletions.
13 changes: 2 additions & 11 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@
"version": "1.1.0"
}
},
{
"package": "swift-backtrace",
"repositoryURL": "https://github.com/swift-server/swift-backtrace.git",
"state": {
"branch": null,
"revision": "f25620d5d05e2f1ba27154b40cafea2b67566956",
"version": "1.3.3"
}
},
{
"package": "swift-collections",
"repositoryURL": "https://github.com/apple/swift-collections.git",
Expand Down Expand Up @@ -186,8 +177,8 @@
"repositoryURL": "https://github.com/vapor/vapor.git",
"state": {
"branch": null,
"revision": "d53f7fdbf6bdaaa4568dc9bf3847aafeaea6c489",
"version": "4.80.0"
"revision": "03a08f6e88d5ca8c1cfd84f8367b21dfe050d082",
"version": "4.81.0"
}
},
{
Expand Down
39 changes: 24 additions & 15 deletions Sources/App/routes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,32 @@ private func swiftPackageInfo(_ app: Application) -> [PackageInfo] {
}
}

private let defaultCodeSnippet = #"""
import Foundation
func greet(_ something: String) -> String {
let greeting = "Hello, " + something + "!"
return greeting
private func escape(_ s: String) -> String {
s
.replacingOccurrences(of: #"\"#, with: #"\\"#)
.replacingOccurrences(of: #"`"#, with: #"\`"#)
}

// Prints "Hello, World!"
print(greet("World"))
private let defaultCodeSnippet = #"""
import Foundation
// Prints "Hello, Swift!"
print(greet("Swift"))
let hello = "Hello, world!"
let multilineString = """
@@@
@@ @@@@
@@ @@@ @@@@@
@@@@@@@@@ @@@@@
@@@@@@@@@@ @@@@@@
@@@@@@@@@@ @@@@@@
@@@@@@@@@@@@@@@@@
@ @@@@@@@@@@@@@@@
@@@@@@ @@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@ @
\(hello)
"""
print(multilineString)
"""#

private func escape(_ s: String) -> String {
s.replacingOccurrences(of: #"\"#, with: #"\\"#)
.replacingOccurrences(of: #"`"#, with: #"\`"#)
}
Loading

0 comments on commit ca2bb5b

Please sign in to comment.