본문 바로가기

Document 해석/PUG

Pug(Jade)의 옵션

728x90
반응형
이 글은 NodeJS 템플릿 엔진인 Pug의 document를 해석한 글입니다.
영어 원문은 아래 바로가기를 클릭하거나 현재 글의 해석 아래 더보기를 클릭 시 확인하실 수 있습니다.
오타나 잘못된 해석은 댓글로 알려주시면 정정하겠습니다.

현재 페이지 본문 바로가기

이 페이지는 JavaScript API를 사용하여 Pug를 렌더링하는 방법이 자세하게 나와 있습니다.


Pug는 당신의 웹 브라우저 콘솔에서 사용할 수 있습니다!
이 페이지에서 문서화된 Pug의 API를 테스트하려면 다음을 입력하십시오.
pug.render('p Hello world!');

옵션

모든 API method는 다음과 같은 옵션 세트를 사용합니다.

filename: string

컴파일 중인 파일의 이름

예외에서 사용되며, 상대적 요구 사항에는 \s를 포함하는 것과 \s를 확장하는 것이 필요 (?)

기본값(default)은 'Pug'

더보기

The name of the file being compiled.
Used in exceptions, and required for relative include\s and extend\s.
Defaults to 'Pug'.

basedir: string

모든 절대 포함의 루트 디렉토리 (??)

더보기

The root directory of all absolute inclusion.

doctype: string

doctype이 템플릿의 일부로 지정되지 않은 경우, 여기에 지정할 수 있음

때때로 자체 닫기 태그를 가져오거나 boolean 속성의 미러링을 제거하기에 유용

자세한 내용은 doctype 문서를 확인하세요.

더보기

If the doctype is not specified as part of the template, you can specify it here.
It is sometimes useful to get self-closing tags and remove mirroring of boolean attributes.
See doctype documentation for more information.

pretty: boolean | string

[중요도가 떨어져 더이상 사용되지 않고 앞으로는 사라지게 될 옵션]

결과 HTML에 공백을 추가하여 ' ' 들여쓰기를 사용해 사람이 읽기 쉽도록 만듦

문자열이 지정된 경우, 대신 들여쓰기로 사용 (예: '\t')

이 옵션은 사용하지 않는 것을 강하게 추천

공백(whitespace)의 해석과 렌더링을 변경하는 방법때문에 템플릿에 미묘한 버그를 만드는 경우가 많아 이 기능은 제거

기본값(default)은 'false'

더보기

[Deprecated.] Adds whitespace to the resulting HTML to make it easier for a human to read using '  ' as indentation.
If a string is specified, that will be used as indentation instead (e.g. '\t').
We strongly recommend against using this option.
Too often, it creates subtle bugs in your templates because of the way it alters the interpretation and rendering of whitespace, and so this feature is going to be removed.
Defaults to false.

filters: object

사용자 지정 필터의 hash table

기본값(default)은 'undefined'

더보기

Hash table of custom filters. Defaults to undefined.

self: boolean

자체 namespace를 사용하여 locals를 보유

컴파일 속도는 빨라지지만, locals 개체(object)의 속성(property)에 접근하려면 변수를 쓰는 대신 self.variable을 작성

기본값(default)은 'false'  

더보기

Use a self namespace to hold the locals.
It will speed up the compilation, but instead of writing variable you will have to write self.variable to access a property of the locals object.
Defaults to false.

debug: boolean

true로 설정하면 token 및 function body가 stdout에 기록

더보기

If set to true, the tokens and function body are logged to stdout.

compileDebug: boolean

true로 설정하면, 더 나은 오류 메시지를 위해 function 소스가 컴파일된 템플릿에 포함 (개발시 유용하기도 함)

production 모드에서 Express와 함께 사용하지 않는한 기본적으로 활성화됨

더보기

If set to true, the function source will be included in the compiled template for better error messages (sometimes useful in development).
It is enabled by default, unless used with Express in production mode.

globals: Array<string>

템플릿에 접근할 수 있도록 전역(global) 이름 목록을 만듦

더보기

Add a list of global names to make accessible in templates.

cache: boolean

true로 설정하면, 컴파일된 function이 캐시됨

파일 이름을 캐시 키로 설정해야 함

렌더링 기능에만 적용

기본값(default)는 false

더보기

If set to true, compiled functions are cached. 
filename must be set as the cache key.
Only applies to render functions.
Defaults to false.

inlineRuntimeFunctions: boolean

공유된 버전에서 요구(require)하는 대신 인라인 런타임 function (??)

compileClient function에서 기본값(default)은 true (런타임을 포함할 필요 없음)

다른 모든 컴파일이나 렌더링 타입은 기본값(default)이 false

더보기

Inline runtime functions instead of require-ing them from a shared version.
For compileClient functions, the default is true (so that one does not have to include the runtime).
For all other compilation or rendering types, the default is false.

name: string

템플릿 function의 이름

compileClient function에만 적용

기본값(default)은 'template'

더보기

The name of the template function. Only applies to compileClient functions. Defaults to 'template'.

 

728x90
반응형