2016-08-18 3 views
1

Mac에서 ESLint와 함께 Atom Editor를 사용하고 있습니다. 스크립트 태그가있는 html 파일을 열어서 eslint-plugin-html과 linter-eslint를 설치해야합니다. 그러나 일부 html 파일에는 장고 코드가 있고 ESLint는 오류를보고합니다. 구문 분석 오류입니다. 예기치 않은 토큰 %. ESLint가 그러한 서버 측 코드를 어떻게 무시할 수 있는지 조언하십시오. 내 장고 구문을 가진 피Atom ESLint가 서버 측 언어 코드를 무시합니다.

A. 비활성화 specific file extensions

C.에 대한 linting 특정 lines, sections of code, or an entire file

B. 해제에 대한 linting : 여기 내 html 파일이

// some html here 
<script> 
    var foo = { 
     {% for item in items %} 
      {% if item == "foo" %} 
      'foo': 'foo' 
      // etc 

답변

1

일부 옵션 모습입니다 <script> 태그.

이렇게하는 한 가지 방법은 데이터를 자바 스크립트 변수로 가져 와서 자바 스크립트에서 조작하는 것입니다.

views.py

def myview(request): 
    some_django_data = json.dumps(geodata) 
    ... 

template.html

<script> 
    var foo = JSON.parse('{{ some_django_data|safe }}') 
</script> 
<script scr="/path/to/myscript.js"></script> 

myscript.js

foo.forEach(myFunc); 
관련 문제