nodejs jade_ unexpected token' indent'

时间:2015-03-12 11:14:57

标签: node.js pug

我在这段代码中遇到了问题(无论如何,对于我的短期工程很抱歉) 我认为这是一个正确的代码,但不知道为什么它会出现关于缩进的错误?这段代码的任何解决方案或建议:( ?? 你可以忽略我在这段代码中写的韩国语

- if (!isSuccess)
  script
    alert('cannot make a chat room.');
    location.href = '/enter';
- else
  h3 room title : 
    span#roomName= roomName 
    input#leave(type='button', value='나가기')
  #chatWindow(style='width:400px; height:400px; overflow:auto; border:1px solid #000; float:left; margin-right:10px;')
    
  div(style='width:100px; height:400px; overflow:auto; border:1px solid #000;')
    p 참가자
    ul#attendants
      each attendant in attendants
        li(id='attendant-'+attendant)= attendant 
  form
    span#myName #{nickName}
    input(type='text', style='width:300px;')#message
    input(type='submit', value='보내기')

  script(type='text/javascript')
    $(document).ready(function() {
      var room = io.connect('/room'); 
      var chatWindow = $('#chatWindow');
      var messageBox = $('#message');
      var myName = $('#myName').text();
      var attendants = $('#attendants');
      var showMessage = function(msg) {
        chatWindow.append($('<p>').text(msg));     
        chatWindow.scrollTop(chatWindow.height());
      };

      room.on('connect', function() {
        room.emit('join', {roomName:$('#roomName').text(), nickName:myName}); 
      });

      room.on('joined', function(data) {
        if(data.isSuccess) {
          showMessage(data.nickName + '님이 입장하셨습니다.');
          attendants.append($('<li>')
            .attr('id', 'attendant-'+data.nickName)
            .text(data.nickName)); 
        }
      });

      room.on('message', function(data) {
        showMessage(data.nickName + ' : ' + data.msg); 
      });

      room.on('leaved', function(data) {
        showMessage(data.nickName + '님이 나가셨습니다.');
        $('#attendant-'+data.nickName).remove();
      });

      $('form').submit(function(e) {
        e.preventDefault();
        var msg = messageBox.val();
        if ($.trim(msg) !== '') {
          showMessage(myName + ' : ' + msg);
          room.json.send({nickName:myName, msg:msg});
          messageBox.val('');
        }
      });

      $('#leave').click(function(e) {
        room.emit('leave', {nickName:myName});
        location.href='/enter';
      });
    });

 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>

1 个答案:

答案 0 :(得分:1)

如果要在编写内联JS / CSS时添加多行/块,则需要添加.

script.
  alert('cannot make a chat room.');
  location.href = '/enter';

script(type='text/javascript').
  $(document).ready(function() {
    var room = io.connect('/room');