Releases: RandomHashTags/swift-htmlkit
0.13.1: Small fix
Minor update by @RandomHashTags .
- moved exports to a new
Exports.swiftfile - remove
HTMLExpansionResultType.chunksInlinecase as it can be represented usingchunks(also fixed compilation failure if using a Swift compiler >= 6.2)
Full Changelog: 0.13.0...0.13.1
0.13.0
Feature and improvement update by @RandomHashTags
Fixes
- reduced binary size bloat due to mishandling of
SwiftSyntaximports (moved all relevant macro code to theHTMLKitParsemodule) (commit)
Additions
HTMLKitParseproduct inPackage.swiftHTMLElementTypenow conforms toCaseIterableandHashable(commit)HTMLEncodingnow conforms toEquatable(commit)- Can now change the expansion result type from an HTML macro (using the new
resultType:option in the macro arguments; now supports chunking or streaming the expansion result)
Changes
- removed file comment headers (commit)
- removed some unnecessary/redundant bytes (type annotation, overrides, certain
returns) - no longer uses
FoundationEssentialsorFoundation(in non-test modules) (commit) innerHTMLis now only[Sendable]instead of[CustomStringConvertible & Sendable](commit)- moved some logic to their own files
- renamed some functions
- a lot of breaking changes (you won't be affected by these if you only use the macros)
- use opaque types instead of generics where applicable (commit)
Full Changelog: 0.12.1...0.13.0
0.12.1
Minor update by @RandomHashTags
Fixes
- interpolation not being warned when within a trailing closure (commit)
Changes
- lowered minimum required platforms by 1 major (commit)
- removed some unnecessary white-space (commit)
- 5 variables in
HTMLExpansionContextare now publicly mutable (werepackage(set)) (commit)
Performance Improvements
- minor performance improvement when removing leading white-space in
parseLiteralValue(commit)
Full Changelog: 0.12.0...0.12.1
0.12.0
QOL update by @RandomHashTags
Fixes
- minor documentation and
README.mdfixes - compilation failure if using Swift < 6.0 (relating to unit tests and Swift Testing) (commit)
- not being able to use multi-line strings for values (commit)
Changes
- only the function call is now warned for unsafe interpolation instead of the whole function, which was visually noisy (commit)
- updated the minimum required platforms (commit)
- use
FoundationEssentialsinstead ofFoundationwhere applicable HTMLElementTypeis now publicly available (commit)- updated
CONTRIBUTING.mdto better reflect Swift standards and best practices (commit) - moved some code to their own modules and files for improved compilation performance and maintainability
- macro expansions now use
HTMLExpansionContextfor its underlying data and settings (commit) - renamed unit test function names to better reflect their intended behavior
- adoption of
Sendableconformance where applicable - replaced a lot of snake_case with camelCase
- changed how HTML elements are rendered (from the
descriptioncomputed property andHTMLElementprotocol)
Additions
- added the
@inlinableannotation to many publicly accessible functions & properties uncheckedHTMLmacro to ignore compiler warnings (commit)anyHTMLmacro; same ashtmlbut returns an existentialrawHTMLmacro that doesn't escape the inner HTML, with the option to minify the resultanyRawHTMLmacro; same asrawHTMLbut returns an existential- can now use a trailing closure to initialize an element's inner HTML
- added a bunch of CSS stuff, but none if it is usable yet due to needing a lot more work to be feature complete
Removals
- removed
StaticStringequality toStringProtocol(commit) - removed some unnecessary type annotations and white space
Full Changelog: 0.11.0...0.12.0
0.11.0
Bug fix update by @RandomHashTags
Fixes
- non-global attribute values not being HTML escaped (commit)
- triple backslash quotation marks not being HTML escaped properly (commit)
- missing attribute value when rendering if the key was wrapped in the "`" character (affected attributes: as, for, default, defer)
- using interpolation in a multi-line context not being compiled correctly (commit, commit)
- html expansion with encodings other than
stringproduce the wrong result (it didn't account for how the string delimiter should be represented) (#3) - certain syntax combinations missing their expected content when being expanded into interpolation, and causing SourceKit and swift-frontend to get stuck in infinite loops (#5, #6)
escapeHTMLmacro not accounting for otherHTMLEncodings (commit)
Breaking changes
- changed the
htmlValuecomputed property tofunc htmlValue(encoding:)forHTMLInitializable(commit)
Additions
- Literal expansion logic for the html macro is now publicly available through
HTMLKitUtilities.expandHTMLMacro(commit) encodingparameter to the#escapeHTMLmacro. Default isstringand, if contained in a#htmlmacro, the parent encoding (commit)CONTRIBUTING.md.swift-format.json
Thanks
A special thanks to @andrebraga for reporting bugs that were fixed in this release!
Full Changelog: 0.10.0...0.11.0
0.10.0
Breaking changes
Content update by @RandomHashTags
Single Macro
This update replaces all html element macros with a single macro. Usage of the html element macros now drop the macro delimiter, compiled via the new #html macro, and should remain at the end of the parameter list to behave identically as before.
The main reason behind this change is due to very poor code completion and compilation performance in projects that use this project extensively, which even I personally experienced. Plus it no longer pollutes the global namespace with over 100 related macros.
Other Changes
- The
#escapeHTMLmacro remains unchanged, but the macros for different types have been replaced by the newHTMLEncodingparameter in the new html macro. - All attribute values can now accept
nilvalues. Attributes withnilvalues are completely ignored when compiled/rendered. - The
varelement was renamed tovariable - updated README to reflect all these changes (and updated benchmark pngs)
Removals
- Removed
swift-niodependency. You will need toimport NIOCoreif you want to useByteBufferas the HTMLEncoding.
New Syntax Examples
Examples of the new syntax
// <div class="dark"><p>Macros are beautiful</p></div>
#html(
div(attributes: [.class(["dark"])],
p("Macros are beautiful")
)
)
// <a href="https://github.com/RandomHashTags/litleagues" target="_blank"></a>
#html(
a(href: "https://github.com/RandomHashTags/litleagues", target: ._blank)
)
// <input id="funny-number" max="420" min="69" name="funny_number" step="1" type="number" value="69">
#html(
input(
attributes: [.id("funny-number")],
max: 420,
min: 69,
name: "funny_number",
step: 1,
type: .number,
value: "69"
)
)Examples of the new HTMLEncoding
#html(
encoding: .string,
div()
)
#html(
encoding: .utf8Array,
div()
)
#html(
encoding: .utf16Array,
div()
)
#html(
encoding: .foundationData,
div()
)
#html(
encoding: .byteBuffer,
div()
)Closing Notes
View the README to learn how to use the new syntax in a more in-depth manner. This update also allows developers to directly call the parsing code via HTMLKitUtilities.parseArguments (and the escape html logic), which allows custom macros to incorporate the HTML expansions, which is especially useful if you want to fully implement a compile time solution for your custom static content (I know I do!).
Also contains a few bug fixes to corner cases and explicit usability.
Full Changelog: 0.9.0...0.10.0
I expect only additions and more fixes to corner cases for the 1.0.0 release. It is pretty much feature complete now, and I will be battle testing it more in the coming weeks.
0.9.0
This update brings a lot of fixes and adds missing attributes for certain elements. Plus HTMX support! (content update by @RandomHashTags )
Additions
- HTMX support via global attributes (view README on how to use)
- experimental
lookupFilesattribute for html macros - added missing
shapeattribute toarea - added missing
command&commandforattributes tobutton - added 5 missing attributes to
form(action, enctype, method, novalidate, target) - added 9 missing attributes to
object(archive, border, classid, codebase, codetype, data, declare, standby, usemap) - added missing
requiredattribute totextarea - added
ariaattributeglobal attribute
Fixes
downloadattribute behavior foracontrolslistattribute behavior foraudioallowattribute behavior foriframerelattribute behavior fora,area,form, &linkhttpEquivattribute behavior formetaautocorrectattribute behavior fortextareaattributionSrcattribute behavior fora,img, &script(and renamed toattributionsrc)
Changes
- empty string attribute value is now kept instead of being completely removed (don't assign the attribute if you don't want it)
- renamed
roleenum inHTMLElementAttribute.Extratoariaroleand added more roles
Other
- organized imports
- README updates
Full Changelog: 0.8.0...0.9.0
This should be the last major update before the 1.0.0 release. Just want to make sure nothing hazardous still exists and the library is feature complete.
0.8.0
Changes
hrefattribute can now contain an empty value (@RandomHashTags , commit)- replaced
runtimeValueNotAllowedcompiler error with automatic interpolation applied plusunsafeInterpolationcompiler warning (@RandomHashTags , commit)
Additions
trailingSlashglobal attribute to support some xhtml; can only be applied to void elements (@RandomHashTags , commit)
Full Changelog: 0.7.1...0.8.0
1.0.0 release is just around the corner, and is expected to release before Nov 16.
0.7.1
Hotfix
- fixed a logic issue when flattening interpolation which resulted in other content contained in the same string that contains the interpolation to be missing; by @RandomHashTags (commit)
Full Changelog: 0.7.0...0.7.1
0.7.0
QOL update
This update adds more compile safety and errors/warnings where applicable when writing your html
Fixes
- Fixed an empty array still populating an attribute and value by @RandomHashTags (commit)
Improvements
- Better Elementary benchmark implementation by @sliemeobn (#1)
- Better interpolation flattening by @RandomHashTags (commit)
- Improved what node is being warned for
unsafeInterpolationcompiler warning by @RandomHashTags (commit) - Improved macro compilation performance by @RandomHashTags (commit, commit)
Additions
- Added macros for return types other than
Stringby @RandomHashTags (commit) - Added
swift-niodependency to supportByteBufferhtml macro return type by @RandomHashTags (commit) - Added logos to badges in README by @RandomHashTags (commit)
- Added compiler error if runtime values are detected by @RandomHashTags (commit)
- Added SwiftDOM to Benchmarks by @RandomHashTags (commit)
Updates
- Updated Benchmark library Elementary to 0.4.1 by @RandomHashTags (commit)
- Use native Swim rendering in benchmarks by @RandomHashTags (commit)
- Updated
eventattribute deprecation message by @RandomHashTags (commit) - Updated
globalAttributeAlreadyDefinedcompiler error message by @RandomHashTags (commit)
Removals
- Removed
StaticStringcomputed variablestringin favor of Swift's nativeStaticString's computed variabledescriptionby @RandomHashTags (commit) - Removed unused
leafdependency in Benchmarks by @RandomHashTags (commit)
Other
- Added funding info by @RandomHashTags (commit)
- various updates to README (including benchmark pngs) to reflect these changes
New Contributors
- @sliemeobn made their first contribution in #1
Full Changelog: 0.6.0...0.7.0