From 1224a5906ac7d10ccc0fbf950da8f4b63aee7ee2 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 5 Apr 2020 17:11:11 +1200 Subject: [PATCH] node: support leaving php context --- fixtures/0003-leave-php-context.php | 14 ++++++++++++++ node.go | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 fixtures/0003-leave-php-context.php diff --git a/fixtures/0003-leave-php-context.php b/fixtures/0003-leave-php-context.php new file mode 100644 index 0000000..be8cb8b --- /dev/null +++ b/fixtures/0003-leave-php-context.php @@ -0,0 +1,14 @@ + + + +

+ + diff --git a/node.go b/node.go index a3030ac..49d1ac4 100644 --- a/node.go +++ b/node.go @@ -3,6 +3,7 @@ package main import ( "fmt" "reflect" + "strconv" //"strconv" "strings" @@ -376,6 +377,15 @@ func convert(n_ node.Node) (string, error) { } return "fmt.Print(" + strings.Join(args, ", ") + ")\n", nil // newline - standalone statement + case *stmt.InlineHtml: + // Convert into fmt.Print + // TODO the result from strconv.Quote is not that nice to maintain if there are multiple newlines + // Should convert it into a backtick-delimeted multiline string instead + return "fmt.Print(" + strconv.Quote(n.Value) + ")\n", nil // newline - standalone statement + + case *stmt.Nop: + return "", nil + // // assign //