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
commit 157391bf6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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