fix some bugs on class name and endif template