-
Notifications
You must be signed in to change notification settings - Fork 68
feat: add RemoveTag engine method #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
b4afb26
5c93d92
aedae6b
a79eab4
0922fc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -305,3 +305,19 @@ func TestIssue63_UnicodeVariableNames(t *testing.T) { | |
| require.Equal(t, "content", string(result)) | ||
| }) | ||
| } | ||
|
|
||
| func TestRemoveTag(t *testing.T) { | ||
| engine := NewEngine() | ||
| engine.RegisterTag("echo", func(c render.Context) (string, error) { | ||
| return c.TagArgs(), nil | ||
| }) | ||
| source := `{% echo hello world %}` | ||
|
|
||
| _, err := engine.ParseAndRenderString(source, emptyBindings) | ||
| require.NoError(t, err) | ||
|
|
||
| engine.RemoveTag("echo") | ||
|
|
||
| _, err = engine.ParseAndRenderString(source, emptyBindings) | ||
| require.Error(t, err) | ||
| } | ||
|
Comment on lines
+309
to
+323
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,8 @@ func (c *Config) FindTagDefinition(name string) (TagCompiler, bool) { | |
| td, ok := c.tags[name] | ||
| return td, ok | ||
| } | ||
|
|
||
| // RemoveTag removes a tag definition. | ||
| func (c *Config) RemoveTag(name string) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider whether this should be This is just a question for you, not a requirement for me to accept the PR. I'm okay with either. Don't do both though! This ends up making it harder to work with client code. |
||
| delete(c.tags, name) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a test, this should go in
engine_test.go. Or rename it toExampleEngine_RemoveTagas a testable example.