Fix issues from Inheritance spec (#36)

* Separate inheritance block and expansion

* Catch top level partial definition, and block newlines

* Add testTrailingNewLines to verify output of trailing newlines in partials

* Remove comment

* If block,partial has indentation add indent for first line

* Re-enable full sections spec

* withBlockExpansion

* Get indentation of blocks correct
This commit is contained in:
Adam Fowler
2024-07-15 09:36:15 +01:00
committed by GitHub
parent cc0eaffa06
commit 7689de0a42
6 changed files with 215 additions and 45 deletions

View File

@@ -87,6 +87,23 @@ struct MustacheContext {
)
}
/// return context with indent information for invoking an inheritance block
func withBlockExpansion(indented: String?) -> MustacheContext {
let indentation: String? = if let indented {
(self.indentation ?? "") + indented
} else {
self.indentation
}
return .init(
stack: self.stack,
sequenceContext: nil,
indentation: indentation,
inherited: self.inherited,
contentType: self.contentType,
library: self.library
)
}
/// return context with sequence info and sequence element added to stack
func withSequence(_ object: Any, sequenceContext: MustacheSequenceContext) -> MustacheContext {
var stack = self.stack