0

This is the pug file for an html view.

Im tryng to put all the h1 elements inside the form but I can't find the way because I obtain different syntax errors.

Now is working with this .pug

doctype html
html
    head
        meta(charset='utf-8')
        meta(name='viewport', content='width=device-width, initial-scale=1, shrink-to-fit=no')
        link(href='https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css', rel='stylesheet')
        title Your first page
    body
form
        h1(id='firstnumber') res
h1(id='plus') +
h1(id='secondnumber') res
h1(id='equal') =
h1(id='result') res     
        script(src='https://code.jquery.com/jquery-3.3.1.min.js')
        script(src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js')
        script(src='https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js')
script(type='text/javascript') console.log("hello"); var x=3; var y=2; var res=x+y; document.getElementById("firstnumber").innerHTML=x; document.getElementById("secondnumber").innerHTML=y; document.getElementById("result").innerHTML=res;

But h1 elements aren't inside the form.

I tried also this:´

doctype html
html
    head
        meta(charset='utf-8')
        meta(name='viewport', content='width=device-width, initial-scale=1, shrink-to-fit=no')
        link(href='https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css', rel='stylesheet')
        title Your first page
    body
        form 
            h1(id='firstnumber') res
            h1(id='plus') +
            h1(id='secondnumber') res
            h1(id='equal') =
            h1(id='result') res     
        script(src='https://code.jquery.com/jquery-3.3.1.min.js')
        script(src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js')
        script(src='https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js')
script(type='text/javascript') console.log("hello"); var x=3; var y=2; var res=x+y; document.getElementById("firstnumber").innerHTML=x; document.getElementById("secondnumber").innerHTML=y; document.getElementById("result").innerHTML=res;

That I believe is the right way but I'm obtaining this Syntax error

1

I'm using Notepad++.

Graham
  • 7,431
  • 18
  • 59
  • 84
Gerardo
  • 21
  • 2
  • 7

1 Answers1

0

The syntax of the second block of code seems good. Some text editors handle tabs spaces differently. The PUG compiler wants you to be consistent in use of these, use spaces, or use tabs.

To set the right options in Notepad++ to use only spaces please have a look at this: Convert tabs to spaces in Notepad++

ToTheMax
  • 981
  • 8
  • 18