node: support leaving php context
This commit is contained in:
parent
d3f238cf01
commit
1224a5906a
14
fixtures/0003-leave-php-context.php
Normal file
14
fixtures/0003-leave-php-context.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$header = "bar";
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<h1><?=$header?></h1>
|
||||||
|
<ul>
|
||||||
|
<?php for($i = 0; $i < 3; ++$i) { ?>
|
||||||
|
<li><?=$i?></li>
|
||||||
|
<?php } ?>
|
||||||
|
</ul>
|
||||||
|
</html>
|
10
node.go
10
node.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
//"strconv"
|
//"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -376,6 +377,15 @@ func convert(n_ node.Node) (string, error) {
|
|||||||
}
|
}
|
||||||
return "fmt.Print(" + strings.Join(args, ", ") + ")\n", nil // newline - standalone statement
|
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
|
// assign
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user