from .library import Library

import datetime

register = Library()


@register.tag(name='now')
def now(parser, token):

    args, kwargs = parser.parse_args(token)

    def _now(context):
        a, k = parser.resolve_args(context, args, kwargs)
        val = datetime.datetime.now()
        return val.strftime(a[0])

    return _now

from .library import Library
from .parse import BasicNode

import datetime

register = Library()


@register.tag(name='now')
class NowNode(BasicNode):
    def render(self, fmt):
        val = datetime.datetime.now()
        return val.strftime(fmt)

Rewrite 'now' tag to use BasicNode
Rewrite 'now' tag to use BasicNode

  from .library import Library
+ from .parse import BasicNode
  
  import datetime
  
  register = Library()
  
  
  @register.tag(name='now')
- def now(parser, token):
+ class NowNode(BasicNode):
+     def render(self, fmt):
+         val = datetime.datetime.now()
+         return val.strftime(fmt)
  
-     args, kwargs = parser.parse_args(token)
- 
-     def _now(context):
-         a, k = parser.resolve_args(context, args, kwargs)
-         val = datetime.datetime.now()
-         return val.strftime(a[0])
- 
-     return _now
- 
Rewrite 'now' tag to use BasicNode
## Code Before:
from .library import Library

import datetime

register = Library()


@register.tag(name='now')
def now(parser, token):

    args, kwargs = parser.parse_args(token)

    def _now(context):
        a, k = parser.resolve_args(context, args, kwargs)
        val = datetime.datetime.now()
        return val.strftime(a[0])

    return _now

## Instruction:
Rewrite 'now' tag to use BasicNode
## Code After:
from .library import Library
from .parse import BasicNode

import datetime

register = Library()


@register.tag(name='now')
class NowNode(BasicNode):
    def render(self, fmt):
        val = datetime.datetime.now()
        return val.strftime(fmt)
