Skip to content

Commit 2c05377

Browse files
committed
native,internal/runtime: introduce the Env.MarkdownConverter method
This change introduces the 'Env.MarkdownConverter' method, which returns the Markdown converter provided to the BuildTemplate function.
1 parent 798dbea commit 2c05377

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

internal/compiler/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
type checkingMod int
2121

2222
// Converter is implemented by format converters.
23-
type Converter func(src []byte, out io.Writer) error
23+
type Converter = func(src []byte, out io.Writer) error
2424

2525
const (
2626
programMod checkingMod = iota + 1

internal/runtime/env.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func (env *env) Fatal(v interface{}) {
4848
panic(&fatalError{env: env, msg: v})
4949
}
5050

51+
func (env *env) MarkdownConverter() Converter {
52+
return env.conv
53+
}
54+
5155
func (env *env) Print(args ...interface{}) {
5256
for _, arg := range args {
5357
env.doPrint(arg)

internal/runtime/vm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var emptyInterfaceType = reflect.TypeOf(&[]interface{}{nil}[0]).Elem()
3131
var emptyInterfaceNil = reflect.ValueOf(&[]interface{}{nil}[0]).Elem()
3232

3333
// Converter is implemented by format converters.
34-
type Converter func(src []byte, out io.Writer) error
34+
type Converter = func(src []byte, out io.Writer) error
3535

3636
// A TypeOfFunc function returns a type of a value.
3737
type TypeOfFunc func(reflect.Value) reflect.Type

native/native.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package native
99

1010
import (
1111
"context"
12+
"io"
1213
"reflect"
1314
)
1415

@@ -30,6 +31,9 @@ type (
3031
Markdown string
3132
)
3233

34+
// Converter is implemented by format converters.
35+
type Converter = func(src []byte, out io.Writer) error
36+
3337
// Env represents an execution environment.
3438
//
3539
// Each execution creates an Env value. This value is passed as the first
@@ -50,6 +54,10 @@ type Env interface {
5054
// functions are not called and started goroutines are not terminated.
5155
Fatal(v interface{})
5256

57+
// MarkdownConverter returns the Markdown converter provided to the
58+
// BuildTemplate function, if one was set.
59+
MarkdownConverter() Converter
60+
5361
// Print calls the print built-in function with args as argument.
5462
Print(args ...interface{})
5563

0 commit comments

Comments
 (0)