mirror of
https://github.com/apple/pkl.git
synced 2026-05-28 01:29:15 +02:00
SPICE-0024: Annotation converters (#1333)
This enables defining declarative key and/or value transformations in cases where neither `Class`- nor path-based converters can be applied gracefully. It is also the only way to express transforming the resulting property names in `Typed` objects without applying a converter to the entire containing type, which is cumbersome at best. SPICE: https://github.com/apple/pkl-evolution/pull/26
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
class LineComment extends ConvertProperty {
|
||||
text: String
|
||||
|
||||
valuePrefix: String = ""
|
||||
prefix: String
|
||||
suffix: String = ""
|
||||
|
||||
render = (prop, renderer) ->
|
||||
Pair(prop.key, new RenderDirective {
|
||||
text =
|
||||
List(
|
||||
valuePrefix,
|
||||
(renderer as ValueRenderer).renderValue(prop.value),
|
||||
prefix,
|
||||
outer.text,
|
||||
suffix,
|
||||
).join("")
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user