neuland / pug4j

a pug implementation written in Java (formerly known as jade)
MIT License
61 stars 12 forks source link

Pug4J.render() method not outputting correct HTML #1

Closed elijahjorell closed 3 years ago

elijahjorell commented 3 years ago

Issue: Pug4J render is not outputting correct html.

I have a simple pug file containing:

doctype html
html
    body
        h1 Heading 1

However when I use the Pug4J render method, it outputs as: <!DOCTYPE htmlnhtmln bodyn h1 Heading 1>

This is being run inside a simple (newly created) servlet

@WebServlet("/HomeServlet")
public class HomeServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public HomeServlet() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("pageTitle", "INDEX PUG VERSION");
        Pug4J.render(getServletContext().getRealPath("/WEB-INF/views/index.pug"), model, response.getWriter());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

I've attached my Eclipse Maven Project below. PugTest.zip

Selaron commented 3 years ago

You are having windows line endings in your index.pug. Converting this to unix line ending style should give better results.

chbloemer commented 3 years ago

Please try 2.0.0-alpha-3