-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating l2format and examples, documentation
- Loading branch information
Showing
6 changed files
with
105 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -997,7 +997,8 @@ <h3 id="cookies-are-sent-as-headers">Cookies are sent as headers<a class="header | |
</code></pre></div> | ||
<h3 id="environment-variables-switch-base-url">Environment Variables: Switch base URL<a class="headerlink" href="#environment-variables-switch-base-url" title="Permanent link">¶</a></h3> | ||
<h4 id="api-variables-can-be-defined-in-apirequestl2">API variables can be defined in <code>apirequest.l2</code><a class="headerlink" href="#api-variables-can-be-defined-in-apirequestl2" title="Permanent link">¶</a></h4> | ||
<p>L2 uses the variables declared inside the <code>.l2</code> file and makes the request</p> | ||
<p>Variables are declared within the JS processor block and serve as dynamic placeholders for data used in API requests. | ||
By utilizing these variables, L2 enables flexibility and reusability in defining API endpoints and data payloads.</p> | ||
<p>Example <code>login.l2</code>:</p> | ||
<div class="highlight"><pre><span></span><code>let REMOTE = "httpbin.org" | ||
let EMAIL = "[email protected]" | ||
|
@@ -1013,25 +1014,23 @@ <h4 id="api-variables-can-be-defined-in-apirequestl2">API variables can be defin | |
</code></pre></div> | ||
<p>Get <a href="https://github.com/HexmosTech/Lama2/tree/main/examples/0021_varjson_variable/0021_varjson_variable.l2">Source Files</a></p> | ||
<h4 id="api-environment-variables-can-be-defined-locally-in-l2env">API environment variables can be defined locally in <code>l2.env</code><a class="headerlink" href="#api-environment-variables-can-be-defined-locally-in-l2env" title="Permanent link">¶</a></h4> | ||
<p><code>l2.env</code> is searched for, from the present directory and variables(local) are loaded from this file.</p> | ||
<p>Example <code>l2.env</code>:</p> | ||
<div class="highlight"><pre><span></span><code>export PHOTO=`base64 aadhaarlarge.jpg` | ||
export AHOST="http://localhost:8000" | ||
</code></pre></div> | ||
<p>L2 provides a convenient way to define environment variables through the l2.env file. | ||
This file is automatically searched for in the present directory, | ||
and its contents are loaded to create a set of variables(local).</p> | ||
<p>In the <code>l2.env</code> file, you can specify environment-specific values for variables used in your L2 scripts, such as URLs, authentication tokens, or any other data that may vary depending on the environment in which the API requests are executed.</p> | ||
<p><img alt="l2.env at API level" src="l2env.png" /></p> | ||
<p>Go to <a href="https://hexmos.com/lama2/tutorials/examples.html#case-1-l2env-adjacent-to-an-api-file">Example</a></p> | ||
<p>Get <a href="https://github.com/HexmosTech/Lama2/tree/main/examples/0023_l2env_declare">Source File</a></p> | ||
<h4 id="api-environment-variables-can-be-defined-at-project-root-using-l2configenv">API environment variables can be defined at project root using <code>l2config.env</code><a class="headerlink" href="#api-environment-variables-can-be-defined-at-project-root-using-l2configenv" title="Permanent link">¶</a></h4> | ||
<p><code>l2config.env</code> is searched for, from the present directory to all its ancestors (upto <code>/</code>) and | ||
variables(root) are loaded from this file. | ||
Example <code>l2config.env</code>:</p> | ||
<div class="highlight"><pre><span></span><code>export PHOTO=`base64 aadhaarsmall.jpg` | ||
export AHOST="http://localhost:8001" | ||
</code></pre></div> | ||
<p>The <code>l2config.env</code> file serves as a centralized storage for environment variables located at the project root, streamlining the management of configuration settings across all L2 scripts. With this file present, every L2 script within the project automatically inherits the defined variables, effectively eliminating the necessity to duplicate configurations in individual subdirectories using <code>l2.env</code>.</p> | ||
<p>The search for <code>l2config.env</code> extends from the present directory up to the root directory (<code>/</code>). During this process, the variables defined in the root file are loaded and made available for use in all relevant scripts. This approach significantly enhances efficiency and maintainability, as it ensures consistent settings throughout the project while reducing redundancy in configuration data.</p> | ||
<p><img alt="l2config.env at Project root level" src="l2configAtRoot.png" /></p> | ||
<p>Go to <a href="https://hexmos.com/lama2/tutorials/examples.html#case-2-root-variables">Example</a></p> | ||
<p>Get <a href="https://github.com/HexmosTech/Lama2/tree/main/examples/0022_l2config_declare">Source File</a></p> | ||
<h4 id="if-l2configenvroot-variables-are-redeclared-in-l2envlocal">If <code>l2config.env</code>(root) variables are redeclared in <code>l2.env</code>(local)<a class="headerlink" href="#if-l2configenvroot-variables-are-redeclared-in-l2envlocal" title="Permanent link">¶</a></h4> | ||
<p>The local variable's value is taken into consideration regardless of both files residing in same directory</p> | ||
<p>In situations where both root and local variables share the same variable name, the local variable takes precedence over the root variable. This behavior remains consistent, even if both <code>l2config.env</code> (root) and <code>l2.env</code> (local) files reside in the same directory. The local variable's value will always be considered over the root variable, ensuring that specific configurations defined at the local level effectively override any corresponding settings present in the root file. This approach provides developers with granular control and flexibility in tailoring environment variables to suit specific needs within different parts of the project while maintaining the overall structure and organization of configuration settings.</p> | ||
<p><img alt="l2config.env at Project root level" src="l2envOverideL2config.png" /></p> | ||
<p>Go to <a href="https://hexmos.com/lama2/tutorials/examples.html#case-3-override-root-variable-with-local-variable">Example</a></p> | ||
<p>Get <a href="https://github.com/HexmosTech/Lama2/tree/main/examples/0020_override_project_root_local">Source File</a></p> | ||
<h3 id="the-environment-file-can-load-results-of-commands">The environment file can load results of commands<a class="headerlink" href="#the-environment-file-can-load-results-of-commands" title="Permanent link">¶</a></h3> | ||
<p>Use the backtick notation <code>\</code>command`` to place the results of | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters