What are the limitations of NDjango templates for regular Django templates?

Are there any differences, limitations, or errors between the NDjango and Django templates? I am particularly interested in their implementation in future ASP.NET MVC projects.

I'm sure I can’t use any of my own template tags that I wrote for Django, but can I transfer them to NDjango?

+3
source share
1 answer

yes you would. you can expand the default tag and set the filter by writing your own and registering them when the application starts. there is only one thing to keep in mind - filters should have been very easily expanded, and therefore you just need to implement one of two straightforward interfaces (ISimpleFilter for parameterless filters or IFilter for filters with 1 parameter). For tags, the concept is the same, but since NDjango itself is written in F #, the ITag interface is a bit more difficult to consume with C # or VB. This is certainly doable, but a bit messy. From F # it is very simple.

in f # is as follows:

/// A single tag implementation
and ITag = 
    /// Transforms a {% %} tag into a list of nodes and uncommited token list
    member Perform: Lexer.BlockToken -> IParser -> 
             Lexer.Token seq -> (Node list * Lexer.Token seq)

in C #, it looks like this:

    public Tuple<FSharpList<Interfaces.Node>, IEnumerable<Lexer.Token>>
              Perform(Lexer.BlockToken __p1, Interfaces.IParser __p2,
                   IEnumerable<Lexer.Token> __p3)

again - the filters are simple in C # - in fact, most of the filters that come with it are written in C #. tags are easy in f # but the messier bit in c #

, , , .

- ndjango.

+4

Source: https://habr.com/ru/post/1708902/


All Articles