mirror of
https://github.com/laosb/SwiftTailwind.git
synced 2025-11-28 22:01:38 +00:00
First working version.
This commit is contained in:
parent
2f70b79493
commit
8fbeb20900
6 changed files with 227 additions and 2 deletions
57
Sources/SwiftTailwindExample/Example.swift
Normal file
57
Sources/SwiftTailwindExample/Example.swift
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import Foundation
|
||||
|
||||
public struct Example {
|
||||
public var htmlInSwiftCode =
|
||||
"""
|
||||
<html>
|
||||
<head>
|
||||
<title>Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="text-2xl">Hello, World!</h1>
|
||||
<p>This is an example of HTML in Swift code.</p>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
public func getTestHTML() throws -> String? {
|
||||
guard let fileURL = Bundle.module.path(forResource: "Test", ofType: "html") else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return try String(contentsOfFile: fileURL, encoding: .utf8)
|
||||
}
|
||||
|
||||
public func getGeneratedCSS() throws -> String? {
|
||||
guard
|
||||
let tailwindCSSBundleURL = Bundle.module.url(
|
||||
forResource: "TailwindCSS", withExtension: "bundle")
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let cssFileURL = tailwindCSSBundleURL.appendingPathComponent("tw.css")
|
||||
return try String(contentsOf: cssFileURL, encoding: .utf8)
|
||||
}
|
||||
|
||||
public func printAll() {
|
||||
print("HTML in Swift Code:")
|
||||
print(htmlInSwiftCode)
|
||||
|
||||
print()
|
||||
print("Test.html:")
|
||||
if let testHTML = try! getTestHTML() {
|
||||
print(testHTML)
|
||||
} else {
|
||||
print("Test.html not found.")
|
||||
}
|
||||
|
||||
print()
|
||||
print("Output Tailwind CSS (minified):")
|
||||
if let generatedCSS = try! getGeneratedCSS() {
|
||||
print(generatedCSS)
|
||||
} else {
|
||||
print("Tailwind CSS not found.")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue