Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Example added on how to overwrite a knockoutjs html file #8367

Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/guides/v2.3/javascript-dev-guide/javascript/requirejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ paths: {
}
```

Consider the example of overwriting an HTML file in the adminhtml.
In this example, the `max-length` value of the text-box in the `adminhtml` is altered. The HTML file is located at `vendor/magento/module_ui/view/base/web/templates/form/element/input.html`

- Create a `requirejs-config.js` file under `app/code/<Vendor_Name>/<Module_Name>/view/base/`

```javascript
var config = {
paths: {
'ui/template/form/element/input': '<vendor_name>_<module_name>/template/form/element/input'
}
};
```

- Create an `input.html` file under `app/code/<Vendor_Name>/<Module_Name>/view/base/web/template/form/` and copy the contents of the `input.html` file from the `module_ui` template file.

{:.bs-callout-info}
The path for `Magento_Ui/templates` is set to be `ui/template` in the `requirejs-config.js` module of `module_ui`, hence `ui/template` is used for specifying the path. If no paths are set, `<module_name>/templates` should be used.

- Change the maxlength value to be `512` which was originally set to be `256`.
- Run the Magento setup upgrade and setup compile commands.
- Confirm the modification by inspecting the element source code and check the `maxlength` value which should have changed to `512` as specified in the template.

### deps {#requirejs-config-deps}

The `deps` configuration is used to add a dependency. It can either be used directly under `var config = {}` or under a [shim configuration](#requirejs-config-shim). Adding modules under an independent `deps` configuration will load the specified modules in all pages.
Expand Down