-
Notifications
You must be signed in to change notification settings - Fork 53
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
fixed unknown block or directive error #45
fixed unknown block or directive error #45
Conversation
mofantor
commented
Apr 10, 2024
- Added WithSkipValidBlocks option to skip valid sub-directives in blocks
- Skip valid blocks by default (e.g., types, map)
* Added WithSkipValidBlocks option to skip valid sub-directives in blocks * Skip valid blocks by default (e.g., types, map)
omg I love it! Thanks @mofantor |
@@ -194,7 +204,7 @@ func (p *Parser) Parse() (*gonginx.Config, error) { | |||
} | |||
|
|||
// ParseBlock parse a block statement | |||
func (p *Parser) parseBlock(inBlock bool) (*gonginx.Block, error) { | |||
func (p *Parser) parseBlock(inBlock bool, isSkipValidDirective bool) (*gonginx.Block, error) { |
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.
@mofantor I like the solution here, do you think you can pass the all options (for the future when we need to check more options recursively) here?
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.
probably not, and if we need to check more options ,we should use options collection to pass and validate( for future)
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.
@tufanbarisyildirim I have just finished two tasks in the project and I am ready to submit PR. If you are interested, you can come to the project and have a look。
- move any context wrapper into their own file (remove from parser)
- link the parent directive to any directive for easier manipulation
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.
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.
Yeah I already saw them, would love to see they are merging here! I will allocate some more time to go over today.
map | ||
` | ||
|
||
var SkipValidBlocks map[string]struct{} = map[string]struct{}{} |
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.
can you write a small comment here to make the linter happy? @mofantor
package parser | ||
|
||
import "strings" | ||
|
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.
// skipValidBlocks defines a list of valid blocks to be skipped during initialization.
// This string is split by newline characters, with each trimmed block name added to the SkipValidBlocks mapping.
map | ||
` | ||
|
||
var SkipValidBlocks map[string]struct{} = map[string]struct{}{} |
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.
// SkipValidBlocks is a mapping used to store names of valid blocks that should be skipped.
// An empty struct is used as the value type to occupy minimal space, serving only as a presence indicator