From 3a96694b81deb46c6932c4b4bdd3432c9e156f16 Mon Sep 17 00:00:00 2001 From: Jaemin Shin <jaminshiny@ajou.ac.kr> Date: Sun, 22 Dec 2024 20:49:39 +0900 Subject: [PATCH] Update file api.rst --- jinja-kr/docs/api.rst | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/jinja-kr/docs/api.rst b/jinja-kr/docs/api.rst index 683ea7c..ee116d5 100644 --- a/jinja-kr/docs/api.rst +++ b/jinja-kr/docs/api.rst @@ -11,9 +11,9 @@ Jinja 탬플릿을 만드는 사람들 보다는 어플리케이션의 인터페 Basics ------ -Jinja는 핵심 개체로 탬플릿 :class:`Environment`를 사용합니다. +Jinja는 핵심 개체로 탬플릿 :class:`Environment`(환경)를 사용합니다. 이 개체의 instance는 구성과 전역변수를 저장하고 파일 시스템 또는 다른 위치로부터 탬플릿을 로드합니다. -당신이 :class:`Template`의 생성자를 사용하여 탬플릿을 만들더라도, 공유되는 :class:`Environment`를 자동적으로 생성합니다. +당신이 :class:`Template`의 생성자를 사용하여 탬플릿을 만들더라도, 공유되는 환경을 자동적으로 생성합니다. 대부분의 어플리케이션은 초기 실행될때 하나의 :class:`Environment` 객체를 생성하고 탬플릿들을 호출합니다. 다만 다른 구성들이 사용되는 경우에는 경우에 따라 복수의 환경을 사용하는 것이 유리합니다. @@ -29,35 +29,26 @@ Jinja는 핵심 개체로 탬플릿 :class:`Environment`를 사용합니다. autoescape=select_autoescape() ) -이것은 탬플릿 +이것은 파이썬 패키지인 ``yourapp`` 내부에 ``templates`` 폴더(또는 파이썬 모듈 ``yourapp.py`` 옆)에서 탬플릿들을 찾는 호출자(loader)와 HTML 파일들 에서 autoescape가 정의된 탬플릿 환경을 생성합니다. +호출자(loader)가 동작하기 위해서는 적어도 ``yourapp``이 가져오기(importable) 가능해야 하고 그때 폴더의 경로를 이해합니다. -This will create a template environment with a loader that looks up -templates in the ``templates`` folder inside the ``yourapp`` Python -package (or next to the ``yourapp.py`` Python module). It also enables -autoescaping for HTML files. This loader only requires that ``yourapp`` -is importable, it figures out the absolute path to the folder for you. +다른 호출자들은 탬플릿을 다른 방법이나 다른 위치로부터 호출할 수 있습니다. 그런 호출자들은 아래 `Loaders`_에 정리되어 있습니다. +또한 프로젝트에 더 특화된 소스로부터 탬플릿을 호출하도록 직접 구성할 수도 있습니다. -Different loaders are available to load templates in other ways or from -other locations. They're listed in the `Loaders`_ section below. You can -also write your own if you want to load templates from a source that's -more specialized to your project. - -To load a template from this environment, call the :meth:`get_template` -method, which returns the loaded :class:`Template`. +이 환경으로부터 탬플릿을 호출하기 위해서는, :meth:`get_template` 메소드를 사용합니다. .. code-block:: python template = env.get_template("mytemplate.html") -To render it with some variables, call the :meth:`render` method. +몇몇 변수와 함꼐 렌더링 하기 위해서는 :meth:`render` 메소드를 활용합니다 .. code-block:: python print(template.render(the="variables", go="here")) -Using a template loader rather than passing strings to :class:`Template` -or :meth:`Environment.from_string` has multiple advantages. Besides being -a lot easier to use it also enables template inheritance. +탬플릿 호출자를 사용하는 것은 :class:`Template`나 :meth:`Environment.from_string`를 통해 문자열을 전송하는 것 보다 많은 장점을 갖습니다. +이는 사용이 쉽고 상속 또한 가능합니다. .. admonition:: Notes on Autoescaping @@ -66,13 +57,12 @@ a lot easier to use it also enables template inheritance. configure autoescaping now instead of relying on the default. -High Level API +상위 수준 API -------------- -The high-level API is the API you will use in the application to load and -render Jinja templates. The :ref:`low-level-api` on the other side is only -useful if you want to dig deeper into Jinja or :ref:`develop extensions -<jinja-extensions>`. +상위 수준 API는 Jinja 템플릿을 호출하고 렌더링하는 데 사용하는 API입니다. +:ref:`low-level-api`는 Jinja를 보다 더 심도 깊게 사용하거나 :ref:`develop extensions<jinja-extensions>`를 활용하기 위해 필요합니다. + .. autoclass:: Environment([options]) :members: from_string, get_template, select_template, -- GitLab