append div with another div content using xpath - xpath

I want to append div using xpath inheriting a parent template.
for ex.
this is parent template
<template id="parent_id">
<div id="header">
<div class="container">
<h1> HEADER </h1>
</div>
</div>
<div id="product">
<div class="container">
<!-- THERE IS SOME CONTENT -->
</div>
</div>
</template>
i want to change like this,
<template id="parent_id">
<div id="product">
<div class="inner">
<div class="container">
<!-- THERE IS SOME CONTENT -->
</div>
</div>
</div>
</template>
i try this,
<template id="product_custom" inherit_id="parent_id">
<xpath expr="//div[#id='product']" position="after">
<div class="inner">
</xpath>
</template>
while replace all content is easy or copy all content to custom template, but it not proper way. i want to wrap a div on content.

I think you cannot do that, because you are going either to override the content or to place your <div/> before, after on inside the selected element.
A simple solution will be to give the id="product" div the class inner by using position="attributes". Or if you really need this, a possible solution is:
replace id="product" with class="inner" with one override using attributes position
define your own template in a second override and call the original one inside it
You will end up with something like this:
<template id="my_parent" inherit_id="foo.parent_id">
<div id="product">
<t t-call="foo.parent_id" />
</div>
</template>
plus the override of the attributes. Never done something like this and the code above is not tested but it could work ;)

Related

Vue Named Slot Won't Render Text or Divs That Contain Text Vue 2

I have created some reusable Modal components moving our app away from jQuery and Bootstrap.
I patterned these components after the components in Laravel Jetstream (Inertia) stack.
First I have a top level DialogContainer which houses the transitions and backdrop and then a generic slot. This top level component is also wrapped in a call to portal-vue so that all my modals are sent to the dialog-helper.
For brevity I'll remove all the Tailwind classes which are straight from TailwindUI.
<template>
<portal to="dialog-helper">
<Transition attrs>
...
<div v-show="show" class="classes">
<slot v-if="show" />
</div>
</Transition>
</portal>
</template>
Next I have several different types of Dialogs, a Fullscreen, Footed, Confirm, Plain Panel etc. These all have named slots for different sections, and are wrapped with the DialogContainer
Confirm Dialog
<template>
<DialogContainer :show="show" :max-width="maxWidth" :closeable="closeable" #close="closeDialog">
...
<h3 class="classes">
<slot name="title" />
</h3>
...
<div class="classes">
<slot name="content" />
</div>
...
<div class="classes">
<CancelButton />
<ConfirmButton />
</div>
...
</DialogContainer>
</template>
Then when I want to use the confirm dialog in a template:
<ConfirmDialog :show="isOpen" #close="isOpen = false" #confirmed="someMethod">
<template #title>Are You Sure You Want to Delete This Item?</template>
<template #content>Deleting this will cause a complete nuclear meltdown, this isn't reversable!</template> // this works
<template #content>
<div class="row">
<div class="form-group col-md-12" :class="{ 'has-error': validation.max }">
<label class="control-label">Maximum Percentage</label>
<input class="form-control" v-model="form.max" placeholder="Maximum ..." type="number" />
<span class="help-block" v-if="validation.max">
{{ validation.max[0] }}
</span>
</div>
</div>
</template> // This works fine, no problems.
<template #content>
<div class="alert alert-warning">
Romantic notes required for Christmas will get auto-populated on the document when rendered.
</div>
</template> // won't open and gives no error in console
<template #content>
<WarningAlert> // even wrapped in a component ...
<p>Romantic notes required for Christmas will get auto-populated on the document when rendered.</p>
</WarningAlert>
</template> // NOPE, this doesn't work either.
</ConfirmDialog>
Can anyone tell me what I'm doing wrong, this exact strategy works in Jetstream, but something isn't working for me here.
UPDATE
I've discovered that I'm able to place plain text up to 109 characters in length. After that it fails ... wth?

Bootstrap wrapping the components too much

Picture
Hi, this is my design right now and i want to expand it more but something is limiting me.
<div className="position-absolute start-50 translate-middle-x">
<div className="d-flex">
<div className="me-2">
<Posts />
</div>
<div className="col">
<GroupPage />
</div>
</div>
</div>
I use d-flex to add element by : by.
I want to expand it to almost whole screen but no luck.

Display data with an AngularJS ng-repeat, in a div, side by side

I have an arraylist from which I need to get values where isActive = true, and to display the data in a <div> tag with the use of ng-repeat.
My problem is that I don't want to keep using ng-repeat every time, while fetching values in each <div> tag.
Is there any generic solution which will iterate only once, and I can see the value in <div>, side by side. Please see this attempt:
enter link description here
I want to see a result like this:
You can write your ng-repeat like below.
Whenever it get isActive true, it will create the div section for this.
<body ng-controller="MainCtrl">
<div ng-repeat="tempData in data">
<div ng-if="tempData.isActive == true" >
<div class="col-xs-12" >
<div class="col-xs-4">Plan Type:</div>
<div class="col-xs-8">{{tempData.plantype}}</div>
</div>
<div class="col-xs-12">
<div class="col-xs-4">Term:</div>
<div class="col-xs-8">{{tempData.term}}</div>
</div>
<div class="col-xs-12">
<div class="col-xs-4">Rate:</div>
<div class="col-xs-8">{{tempData.rate}}</div>
</div>
</div>
</div>
</body>

How to use regular expression clear content inside div

I have this code
<div class="kakaa">
<div class="hihi">
<div>dfsfsdf</div>
<div class="haha">
<div id="kaka">ohfoehwf</div>
</div>
</div>
<div class="main">
<div>lorem</div>
</div>
</div>
Now, i want to remove div has class hihi, how to do it become
<div class="kakaa">
<div class="main">
<div>lorem</div>
</div>
</div>
You didn't specify if you're doing this on server-side or client-side. If client-side, no regex is necessary. Use jQuery:
$('.hihi').remove();
Here's a reference: http://api.jquery.com/remove/
If you're doing it server-side, don't use regex (you'll never be able to cover all the possibilities in an HTML tag with regex). Instead use a HTML DOM parser. Here's a very simple one: http://simplehtmldom.sourceforge.net/

Looking for all descendant elements which parent does not have this css class

I am trying to get all children which has specific class and parent of this parent does not have a specific class.
I am trying a code like this, but it's not working.
$hrefs = $xpath->evaluate("//div[not contains(#class, 'tested-app-section')]/div[#class='product-container-body']/div");
Structure of the HTML I am working with and need to edit a little bit looks like this, other HTML content in <body> is irrelevant. (<body> contains more then just this block of HTML):
<body>
<div class="product-detail-section tested-app-section">
<div class="product-container-head"> ... </div>
<div class="product-container-body"> ... </div>
<div class="product-container-body"> ... </div>
</div>
<div class="product-detail-section publish-app-section">
<div class="product-container-head"> ... </div>
<div class="product-container-body"> ... </div>
<div class="product-container-body"> ... </div>
</div>
<div class="product-detail-section product-specific-section">
<div class="product-container-head"> ... </div>
<div class="product-container-body"> ... </div>
<div class="product-container-body"> ... </div>
</div>
I am trying to avoid in the result the very first <div> box (box with class "tested-app-section"), then I am trying to avoid everything witch class "product-container-head".
But I just cannot find a way how to do it.
Edit: So basically I am trying to get
/html/body/div[contains(#class, 'product-detail-section') AND not contains(#class, 'tested-app-section')]/div[not(#class='product-container-head')]
but this code doesn't return anything...
You are close, but missed a few things. Try this xpath expression and see if it works:
//div[not(contains(#class, 'tested-app-section'))]/div[not(#class='product-container-head')]

Resources