<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 動態解析器語法 ### [](https://octobercms.com/docs/services/parser#dynamic-syntax-parser)動態語法解析器 動態語法是十月份獨有的模板引擎,從根本上支持兩種渲染模式。解析模板將產生兩個結果,即**視圖**或**編輯器**模式。以該模板文本為例,`{text}...{/text}`標簽的內部部分表示**視圖**模式的默認文本,而內部屬性`name`和`label`用作**編輯器**模式的屬性。 ~~~ <h1>{text name="websiteName" label="Website Name"}Our wonderful website{/text}</h1> ~~~ 該解析器沒有外觀,因此`October\Rain\Parse\Syntax\Parser`應將完全限定的類與該`parse`方法一起使用。該`parse`方法的第一個參數將模板內容作為字符串并返回一個`Parser`對象。 ~~~ use October\Rain\Parse\Syntax\Parser as SyntaxParser; $syntax = SyntaxParser::parse($content); ~~~ ### [](https://octobercms.com/docs/services/parser#syntax-view-mode)查看模式 假設我們使用上面的第一個示例作為模板內容,調用該`render`方法本身將使用默認文本呈現模板: ~~~ echo $syntax->render(); // <h1>Our wonderful website</h1> ~~~ 就像任何模板引擎一樣,將變量數組傳遞給的第一個參數`render`將替換模板中的變量。此處的默認值`websiteName`替換為我們的新值: ~~~ echo $syntax->render(['websiteName' => 'OctoberCMS']); // <h1>OctoberCMS</h1> ~~~ 作為一項額外功能,調用該`toTwig`方法將以準備好的狀態輸出模板,以供[Twig引擎](https://octobercms.com/docs/services/parser#twig-parser)渲染。 ~~~ echo $syntax->toTwig(); // <h1>{{ websiteName }}</h1> ~~~ ### [](https://octobercms.com/docs/services/parser#syntax-editor-mode)編輯器模式 到目前為止,動態語法解析器與常規模板引擎沒有太大區別,但是在編輯器模式下,動態語法的實用性變得更加明顯。編輯器模式開啟了一個新的可能性領域,例如,[布局將自定義表單字段注入到](http://octobercms.com/plugin/rainlab-pages)屬于它們的[頁面](http://octobercms.com/plugin/rainlab-pages)或用于[電子郵件活動中動態生成的表單](http://octobercms.com/plugin/responsiv-campaign)。 繼續上面的示例,`toEditor`在`Parser`對象上調用方法將返回一個PHP屬性數組,該數組定義應如何使用表單生成器填充變量。 ~~~ $array = $syntax->toEditor(); // 'websiteName' => [ // 'label' => 'Website name', // 'default' => 'Our wonderful website', // 'type' => 'text' // ] ~~~ 您可能會注意到,這些屬性與[表單字段定義中](https://octobercms.com/docs/backend/forms#form-fields)的選項非常相似。這是有意的,因此這兩個功能可以相互補充。現在,我們可以輕松地將上面的數組轉換為YAML并寫入`fields.yaml`文件: ~~~ $form = [ 'fields' => $syntax->toEditor() ]; File::put('fields.yaml', Yaml::render($form)); ~~~ ### [](https://octobercms.com/docs/services/parser#syntax-supported-tags)支持的標簽 動態語法解析器可以使用多種標記類型,這些標記類型旨在匹配常見的[表單字段類型](https://octobercms.com/docs/backend/forms#field-types)。 #### 文本 單行輸入,用于較小的文本塊。 ~~~ {text name="websiteName" label="Website Name"}Our wonderful website{/text} ~~~ #### 文字區 多行輸入用于較大的文本塊。 ~~~ {textarea name="websiteDescription" label="Website Description"} This is our vision for things to come {/textarea} ~~~ ### 落下 呈現一個下拉表單字段。 ~~~ {dropdown name="dropdown" label="Pick one" options="One|Two"}{/dropdown} ~~~ 呈現具有獨立值和標簽的下拉表單字段。 ~~~ {dropdown name="dropdown" label="Pick one" options="one:One|two:Two"}{/dropdown} ~~~ 使用靜態類方法(該類必須是完全命名空間的類)返回的數組呈現下拉表單字段。 ~~~ {dropdown name="dropdown" label="Pick one" options="\Path\To\Class::method"}{/dropdown} ~~~ ### 無線電 渲染單選表單字段。 ~~~ {radio name="radio" label="Thoughts?" options="y:Yes|n:No|m:Maybe"}{/radio} ~~~ #### 變量 完全按照`type`屬性中的定義呈現表單字段類型。此標記將僅設置一個變量,并在視圖模式下呈現為空字符串。 ~~~ {variable type="text" name="name" label="Name"}John{/variable} ~~~ #### 豐富的編輯 用于豐富內容的文本輸入(WYSIWYG)。 ~~~ {richeditor name="content" label="Main content"}Default text{/richeditor} ~~~ 在Twig中呈現為 ~~~ {{ content|raw }} ~~~ #### 降價促銷 Markdown內容的文本輸入。 ~~~ {markdown name="content" label="Markdown content"}Default text{/markdown} ~~~ 在Twig中呈現為 ~~~ {{ content|md }} ~~~ #### 媒體搜尋器 媒體庫項目的文件選擇器。該標記值將包含文件的相對路徑。 ~~~ {mediafinder name="logo" label="Logo"}defaultlogo.png{/mediafinder} ~~~ 在Twig中呈現為 ~~~ {{ logo|media }} ~~~ #### 上傳文件 文件的文件上傳器輸入。該標記值將包含文件的完整路徑。 ~~~ {fileupload name="logo" label="Logo"}defaultlogo.png{/fileupload} ~~~ #### 直放站 渲染一個包含其他字段的重復節。 ~~~ {repeater name="content_sections" prompt="Add another content section"} <h2>{text name="title" label="Title"}Title{/text}</h2> <p>{textarea name="content" label="Content"}Content{/textarea}</p> {/repeater} ~~~ 在Twig中呈現為 ~~~ {% for fields in repeater %} <h2>{{ fields.title }}</h2> <p>{{ fields.content|raw }}</p> {% endfor %} ~~~ 調用`$syntax->toEditor`將為轉發器字段返回不同的數組: ~~~ 'repeater' => [ 'label' => 'Website name', 'type' => 'repeater', 'fields' => [ 'title' => [ 'label' => 'Title', 'default' => 'Title', 'type' => 'text' ], 'content' => [ 'label' => 'Content', 'default' => 'Content', 'type' => 'textarea' ] ] ] ~~~ 轉發器字段還支持組模式,該組模式可與動態語法解析器一起使用,如下所示: ~~~ {variable name="sections" type="repeater" prompt="Add another section" tab="Sections" groups="$/author/plugin/repeater_fields.yaml"}{/variable} ~~~ 這是repeater\_fields.yaml組配置文件的示例: ~~~ quote: name: Quote description: Quote item icon: icon-quote-right fields: quote_position: span: auto label: Quote Position type: radio options: left: Left center: Center right: Right quote_content: span: auto label: Details type: textarea ~~~ 有關Repeater組模式的更多信息,請參見[Repeater Widget](https://octobercms.com/docs/backend/forms#widget-repeater)。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看