...

Source file src/github.com/noirbizarre/gonja/ext/django/statements/comment.go

Documentation: github.com/noirbizarre/gonja/ext/django/statements

     1  package statements
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/noirbizarre/gonja/nodes"
     7  	"github.com/noirbizarre/gonja/parser"
     8  	"github.com/noirbizarre/gonja/tokens"
     9  )
    10  
    11  type CommentStmt struct {
    12  	Location *tokens.Token
    13  }
    14  
    15  func (stmt *CommentStmt) Position() *tokens.Token { return stmt.Location }
    16  func (stmt *CommentStmt) String() string {
    17  	t := stmt.Position()
    18  	return fmt.Sprintf("Block(Line=%d Col=%d)", t.Line, t.Col)
    19  }
    20  
    21  func commentParser(p *parser.Parser, args *parser.Parser) (nodes.Statement, error) {
    22  	commentNode := &CommentStmt{p.Current()}
    23  
    24  	err := p.SkipUntil("endcomment")
    25  	if err != nil {
    26  		return nil, err
    27  	}
    28  
    29  	if !args.End() {
    30  		return nil, args.Error("Tag 'comment' does not take any argument.", nil)
    31  	}
    32  
    33  	return commentNode, nil
    34  }
    35  
    36  func init() {
    37  	All.Register("comment", commentParser)
    38  }
    39  

View as plain text