Merge pull request #84 from blue-bird1/dev

fix #78 not use short-tags.
This commit is contained in:
Vadym Slizov
2019-03-20 21:27:17 +02:00
committed by GitHub

View File

@@ -43,8 +43,7 @@ func (p *Printer) SetState(s printerState) {
func (p *Printer) Print(n node.Node) {
_, isRoot := n.(*node.Root)
_, isInlineHtml := n.(*stmt.InlineHtml)
_, isEcho := n.(*stmt.Echo)
if p.s == HtmlState && !isInlineHtml && !isRoot && !isEcho {
if p.s == HtmlState && !isInlineHtml && !isRoot {
if n.GetFreeFloating().IsEmpty() {
io.WriteString(p.w, "<?php ")
}
@@ -2430,21 +2429,13 @@ func (p *Printer) printStmtDo(n node.Node) {
func (p *Printer) printStmtEcho(n node.Node) {
nn := n.(*stmt.Echo)
if p.s == HtmlState {
if nn.GetFreeFloating().IsEmpty() {
io.WriteString(p.w, "<?=")
}
p.SetState(PhpState)
} else {
if nn.GetFreeFloating().IsEmpty() {
io.WriteString(p.w, "echo")
}
if nn.Exprs[0].GetFreeFloating().IsEmpty() {
io.WriteString(p.w, " ")
}
if nn.GetFreeFloating().IsEmpty() {
io.WriteString(p.w, "echo")
}
if nn.Exprs[0].GetFreeFloating().IsEmpty() {
io.WriteString(p.w, " ")
}
p.printFreeFloating(nn, freefloating.Start)
p.printFreeFloating(nn, freefloating.Echo)