How to use if else in x-magento-templateHow to render HTML in x-magento-template?Magento 2 how to write in data-mage-init
How to set Adobe DC PDF reader as default for ALL pdfs without having to open security preferences every time
Went to a big 4 but got fired for underperformance in a year recently - Now every one thinks I'm pro - How to balance expectations?
Declaring a visitor to the UK as my "girlfriend" - effect on getting a Visitor visa?
Can birds evolve without trees?
How long should I wait to plug in my refrigerator after unplugging it?
How do I respond appropriately to an overseas company that obtained a visa for me without hiring me?
What is the difference between "logical equivalence" and "material equivalence"?
Backpacking with incontinence
Feedback diagram
Is Norway in the Single Market?
Map vs. Table for index-specific operations on 2D arrays
Why do we need a voltage divider when we get the same voltage at the output as the input?
Python π = 1 + (1/2) + (1/3) + (1/4) - (1/5) + (1/6) + (1/7) + (1/8) + (1/9) - (1/10) ...1748 Euler
How to avoid a lengthy conversation with someone from the neighborhood I don't share interests with
Can I say "Gesundheit" if someone is coughing?
How to trick a fairly simplistic kill-counter?
How is Sword Coast North governed?
Can an alphabet for a Turing machine contain subsets of other alphabets?
What's the proper way of indicating that a car has reached its destination during a dialogue?
When did J.K. Rowling decide to make Ron and Hermione a couple?
What does the "きゃ" in "していきゃがらなかった" stand for?
Accurately recalling the key - can everyone do it?
Is the EU really banning "toxic propellants" in 2020? How is that going to work?
What is the reason behind water not falling from a bucket at the top of loop?
How to use if else in x-magento-template
How to render HTML in x-magento-template?Magento 2 how to write in data-mage-init
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to use if, in x-magento-template, I try this code and it shows thí
Code :
<% if(fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
Bug :

x-magento-template
add a comment |
I want to use if, in x-magento-template, I try this code and it shows thí
Code :
<% if(fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
Bug :

x-magento-template
please find below answer,magento.stackexchange.com/a/283097/52244 hope this solves your concern.
– Kanhaiya lal
Jul 24 at 6:56
mention your magento version
– Mohit Rane
Jul 24 at 7:46
add a comment |
I want to use if, in x-magento-template, I try this code and it shows thí
Code :
<% if(fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
Bug :

x-magento-template
I want to use if, in x-magento-template, I try this code and it shows thí
Code :
<% if(fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
Bug :

x-magento-template
x-magento-template
edited Jul 24 at 4:41
poojan sharma
1,0632 silver badges10 bronze badges
1,0632 silver badges10 bronze badges
asked Jul 24 at 4:34
TN98TN98
35711 bronze badges
35711 bronze badges
please find below answer,magento.stackexchange.com/a/283097/52244 hope this solves your concern.
– Kanhaiya lal
Jul 24 at 6:56
mention your magento version
– Mohit Rane
Jul 24 at 7:46
add a comment |
please find below answer,magento.stackexchange.com/a/283097/52244 hope this solves your concern.
– Kanhaiya lal
Jul 24 at 6:56
mention your magento version
– Mohit Rane
Jul 24 at 7:46
please find below answer,magento.stackexchange.com/a/283097/52244 hope this solves your concern.
– Kanhaiya lal
Jul 24 at 6:56
please find below answer,magento.stackexchange.com/a/283097/52244 hope this solves your concern.
– Kanhaiya lal
Jul 24 at 6:56
mention your magento version
– Mohit Rane
Jul 24 at 7:46
mention your magento version
– Mohit Rane
Jul 24 at 7:46
add a comment |
2 Answers
2
active
oldest
votes
try following way..
<script id="some-template" type="text/x-magento-template">
<% if (fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
</script>
hi Rakesh Donga, i tryed but it not work
– TN98
Jul 24 at 6:17
add a comment |
You can use mage/template to use these x-magento-template JS templates and render them .
define([
"jquery",
"mage/template"
], function($, mageTemplate)
var warningTemplate = mageTemplate('#some-template');
$('body').append(warningTemplate); // for example added body as refenece area, that can update as per need
);
And the #some-template is:
not have much idea about conditional part fields.branche == "" so instead of added 1 means true in condition to make it work (or to test).
<script id="some-template" type="text/x-magento-template">
<% if(1) %>
<div class="right">
<img style="width: 25px;" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png" title="Google"/>
</div>
<% %>
</script>
For live example see pdp
data-role="cart-item-warning-message-template"on script
(warningTemplate) and template calling js is
Magento_Catalog/js/catalog-add-to-cart
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283071%2fhow-to-use-if-else-in-x-magento-template%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
try following way..
<script id="some-template" type="text/x-magento-template">
<% if (fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
</script>
hi Rakesh Donga, i tryed but it not work
– TN98
Jul 24 at 6:17
add a comment |
try following way..
<script id="some-template" type="text/x-magento-template">
<% if (fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
</script>
hi Rakesh Donga, i tryed but it not work
– TN98
Jul 24 at 6:17
add a comment |
try following way..
<script id="some-template" type="text/x-magento-template">
<% if (fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
</script>
try following way..
<script id="some-template" type="text/x-magento-template">
<% if (fields.branche == "") %>
<div class="right">
<img style="width: 25px;" src="http://ainem.powered-by-rackspeed.de/pub/media/premium/premiumCrown.png" title="Premium-Filiale mit Angeboten"/>
</div>
<% %>
</script>
answered Jul 24 at 4:41
Rakesh DongaRakesh Donga
2,9286 silver badges25 bronze badges
2,9286 silver badges25 bronze badges
hi Rakesh Donga, i tryed but it not work
– TN98
Jul 24 at 6:17
add a comment |
hi Rakesh Donga, i tryed but it not work
– TN98
Jul 24 at 6:17
hi Rakesh Donga, i tryed but it not work
– TN98
Jul 24 at 6:17
hi Rakesh Donga, i tryed but it not work
– TN98
Jul 24 at 6:17
add a comment |
You can use mage/template to use these x-magento-template JS templates and render them .
define([
"jquery",
"mage/template"
], function($, mageTemplate)
var warningTemplate = mageTemplate('#some-template');
$('body').append(warningTemplate); // for example added body as refenece area, that can update as per need
);
And the #some-template is:
not have much idea about conditional part fields.branche == "" so instead of added 1 means true in condition to make it work (or to test).
<script id="some-template" type="text/x-magento-template">
<% if(1) %>
<div class="right">
<img style="width: 25px;" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png" title="Google"/>
</div>
<% %>
</script>
For live example see pdp
data-role="cart-item-warning-message-template"on script
(warningTemplate) and template calling js is
Magento_Catalog/js/catalog-add-to-cart
add a comment |
You can use mage/template to use these x-magento-template JS templates and render them .
define([
"jquery",
"mage/template"
], function($, mageTemplate)
var warningTemplate = mageTemplate('#some-template');
$('body').append(warningTemplate); // for example added body as refenece area, that can update as per need
);
And the #some-template is:
not have much idea about conditional part fields.branche == "" so instead of added 1 means true in condition to make it work (or to test).
<script id="some-template" type="text/x-magento-template">
<% if(1) %>
<div class="right">
<img style="width: 25px;" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png" title="Google"/>
</div>
<% %>
</script>
For live example see pdp
data-role="cart-item-warning-message-template"on script
(warningTemplate) and template calling js is
Magento_Catalog/js/catalog-add-to-cart
add a comment |
You can use mage/template to use these x-magento-template JS templates and render them .
define([
"jquery",
"mage/template"
], function($, mageTemplate)
var warningTemplate = mageTemplate('#some-template');
$('body').append(warningTemplate); // for example added body as refenece area, that can update as per need
);
And the #some-template is:
not have much idea about conditional part fields.branche == "" so instead of added 1 means true in condition to make it work (or to test).
<script id="some-template" type="text/x-magento-template">
<% if(1) %>
<div class="right">
<img style="width: 25px;" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png" title="Google"/>
</div>
<% %>
</script>
For live example see pdp
data-role="cart-item-warning-message-template"on script
(warningTemplate) and template calling js is
Magento_Catalog/js/catalog-add-to-cart
You can use mage/template to use these x-magento-template JS templates and render them .
define([
"jquery",
"mage/template"
], function($, mageTemplate)
var warningTemplate = mageTemplate('#some-template');
$('body').append(warningTemplate); // for example added body as refenece area, that can update as per need
);
And the #some-template is:
not have much idea about conditional part fields.branche == "" so instead of added 1 means true in condition to make it work (or to test).
<script id="some-template" type="text/x-magento-template">
<% if(1) %>
<div class="right">
<img style="width: 25px;" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png" title="Google"/>
</div>
<% %>
</script>
For live example see pdp
data-role="cart-item-warning-message-template"on script
(warningTemplate) and template calling js is
Magento_Catalog/js/catalog-add-to-cart
edited Jul 24 at 6:47
answered Jul 24 at 6:39
Kanhaiya lalKanhaiya lal
1,1935 silver badges20 bronze badges
1,1935 silver badges20 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283071%2fhow-to-use-if-else-in-x-magento-template%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
please find below answer,magento.stackexchange.com/a/283097/52244 hope this solves your concern.
– Kanhaiya lal
Jul 24 at 6:56
mention your magento version
– Mohit Rane
Jul 24 at 7:46