8000 Add ObligatoryPrintDirectives by bhainesva · Pull Request #1 · bhainesva/soy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add ObligatoryPrintDirectives #1

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

Open
wants to merge 2 commits into
base: i18n
Choose a base branch
from
Open

Conversation

bhainesva
Copy link
Owner

This change would allow callers to inject print directives that are applied by default.

Sometimes we accidentally print null variables, this would allow us to inject a directive that renders these as an empty string instead of as the word 'null'.

@bhainesva bhainesva force-pushed the obligatory-directives branch from 449c4ae to 987e3ec Compare January 4, 2018 15:17
soyhtml/exec.go Outdated
@@ -330,6 +330,33 @@ func (s *state) evalPrint(node *ast.PrintNode) {
}
}

for _, directiveName := range ObligatoryPrintDirectiveNames {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you instead append this to the list of node directives on #302 to avoid duplicating the code?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that. It feels a little weird because I have to turn it into a Node which has a Position but the directive doesn't actually appear in the input anywhere. I'll just give it the same position as the PrintNode that it belongs to, I don't think it's too important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0