changeset 2693:3cbd6e440581

Documented the js_var directive.
author Yaroslav Zhuravlev <yar@nginx.com>
date Mon, 29 Mar 2021 19:40:27 +0100
parents 3fe54f96476a
children 1f2bd0d9a06c
files xml/en/docs/http/ngx_http_js_module.xml xml/en/docs/njs/reference.xml xml/en/docs/stream/ngx_stream_js_module.xml xml/ru/docs/http/ngx_http_js_module.xml xml/ru/docs/stream/ngx_stream_js_module.xml
diffstat 5 files changed, 99 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/xml/en/docs/http/ngx_http_js_module.xml
+++ b/xml/en/docs/http/ngx_http_js_module.xml
@@ -9,7 +9,7 @@
 <module name="Module ngx_http_js_module"
         link="/en/docs/http/ngx_http_js_module.html"
         lang="en"
-        rev="27">
+        rev="28">
 
 <section id="summary">
 
@@ -321,6 +321,25 @@ right before the request is freed.
 
 </directive>
 
+
+<directive name="js_var">
+<syntax><value>$variable</value> [<value>value</value>]</syntax>
+<default/>
+<context>http</context>
+<appeared-in>0.5.3</appeared-in>
+
+<para>
+Declares
+a <link doc="../njs/reference.xml" id="r_variables">writable</link>
+variable.
+The value can contain text, variables, and their combination.
+The variable is not overwritten after a redirect
+unlike variables created with the
+<link doc="ngx_http_rewrite_module.xml" id="set"/> directive.
+</para>
+
+</directive>
+
 </section>
 
 
--- a/xml/en/docs/njs/reference.xml
+++ b/xml/en/docs/njs/reference.xml
@@ -9,7 +9,7 @@
 <article name="Reference"
         link="/en/docs/njs/reference.html"
         lang="en"
-        rev="72">
+        rev="73">
 
 <section id="summary">
 
@@ -458,10 +458,26 @@ writable
 <tag-desc>
 nginx variables object, writable
 (since <link doc="changes.xml" id="njs0.2.8">0.2.8</link>).
-A variable can be writable only
-if it is referenced in nginx configuration file.
+
+<para>
+A variable is writable if:
+<list type="bullet">
+
+<listitem>
+it was created using the <literal>js_var</literal> directive for
+<link doc="../http/ngx_http_js_module.xml" id="js_var">http</link> or
+<link doc="../stream/ngx_stream_js_module.xml" id="js_var">stream</link>
+(since <link doc="changes.xml" id="njs0.5.3">0.5.3</link>)
+</listitem>
+
+<listitem>
+it is referenced in nginx configuration file
+</listitem>
+
+</list>
 Even so, some embedded variables still cannot be assigned a value (for example,
 <link doc="../http/ngx_http_core_module.xml" id="var_http_"><literal>$http_</literal></link>).
+</para>
 </tag-desc>
 
 <tag-name id="r_warn"><literal>r.warn(<value>string</value>)</literal></tag-name>
--- a/xml/en/docs/stream/ngx_stream_js_module.xml
+++ b/xml/en/docs/stream/ngx_stream_js_module.xml
@@ -9,7 +9,7 @@
 <module name="Module ngx_stream_js_module"
         link="/en/docs/stream/ngx_stream_js_module.html"
         lang="en"
-        rev="25">
+        rev="26">
 
 <section id="summary">
 
@@ -282,6 +282,25 @@ right before the request is freed.
 
 </directive>
 
+
+<directive name="js_var">
+<syntax><value>$variable</value> [<value>value</value>]</syntax>
+<default/>
+<context>stream</context>
+<appeared-in>0.5.3</appeared-in>
+
+<para>
+Declares
+a <link doc="../njs/reference.xml" id="r_variables">writable</link>
+variable.
+The value can contain text, variables, and their combination.
+The variable is not overwritten after a redirect
+unlike variables created with the
+<link doc="ngx_stream_set_module.xml" id="set"/> directive.
+</para>
+
+</directive>
+
 </section>
 
 
--- a/xml/ru/docs/http/ngx_http_js_module.xml
+++ b/xml/ru/docs/http/ngx_http_js_module.xml
@@ -9,7 +9,7 @@
 <module name="Модуль ngx_http_js_module"
         link="/ru/docs/http/ngx_http_js_module.html"
         lang="ru"
-        rev="27">
+        rev="28">
 
 <section id="summary">
 
@@ -322,6 +322,25 @@ function version(r) {
 
 </directive>
 
+
+<directive name="js_var">
+<syntax><value>$переменная</value> [<value>значение</value>]</syntax>
+<default/>
+<context>http</context>
+<appeared-in>0.5.3</appeared-in>
+
+<para>
+Объявляет
+<link doc="../njs/reference.xml" id="r_variables">перезаписываемую</link>
+переменную.
+В качестве значения можно использовать текст, переменные и их комбинации.
+Переменная не перезаписывается после перенаправления,
+в отличие от переменных, созданных при помощи
+директивы <link doc="ngx_http_rewrite_module.xml" id="set"/>.
+</para>
+
+</directive>
+
 </section>
 
 
--- a/xml/ru/docs/stream/ngx_stream_js_module.xml
+++ b/xml/ru/docs/stream/ngx_stream_js_module.xml
@@ -9,7 +9,7 @@
 <module name="Модуль ngx_stream_js_module"
         link="/ru/docs/stream/ngx_stream_js_module.html"
         lang="ru"
-        rev="25">
+        rev="26">
 
 <section id="summary">
 
@@ -283,6 +283,25 @@ function address(s) {
 
 </directive>
 
+
+<directive name="js_var">
+<syntax><value>$переменная</value> [<value>значение</value>]</syntax>
+<default/>
+<context>stream</context>
+<appeared-in>0.5.3</appeared-in>
+
+<para>
+Объявляет
+<link doc="../njs/reference.xml" id="r_variables">перезаписываемую</link>
+переменную.
+В качестве значения можно использовать текст, переменные и их комбинации.
+Переменная не перезаписывается после перенаправления,
+в отличие от переменных, созданных при помощи
+директивы <link doc="ngx_stream_set_module.xml" id="set"/>.
+</para>
+
+</directive>
+
 </section>