-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Props missing and render problems (don't know how to name the problem) #26
Comments
Hi, sorry for late reply. I think that you are using an old version of the plugin, since I remember this was an issues that I have fixed. I try to reproduce issue in this repo https://github.com/thewebartisan7/posthtml-bootstrap-ui-starter Try clone it and then run
Then check in dist folder file test.html and test2.html, which is the result of this two pages: https://github.com/thewebartisan7/posthtml-bootstrap-ui-starter/blob/main/src/pages/test.html Be sure that you are using last version of the plugin, which is In case doesn't work for your project with latest version, please create a repo where I can reproduce this issue. Thanks! An extra note about your code: This condition: I also prefer to provide a better API to my component, for example see below code, which allow you to use your component like: <x-spacer size="sm"></x-spacer>
<x-spacer size="md"></x-spacer>
<x-spacer size="lg"></x-spacer>
etc... <!-- spacer.html -->
<script props>
module.exports = {
size: {
xs: '10px',
sm: '20px',
md: '30px',
lg: '40px',
xl: '50px'
}[props.size] || false
}
</script>
<if condition="size">
<div style="line-height: {{ size }};" role="separator">‌</div>
</if>
<else>
<div role="separator">‌</div>
</else> |
Hi, thanks for your help and example! Yeah , I used I am using the latest version btw what I noticed in my case, if I use predefined data ( as in the example above ) then everything works fine, but if I use "dynamic" data then it works as I described above. So far I have not found what could be the problem. Maybe in the browserSync && watcher, since during the build everything works fine, but in the devs - no. Sorry for my English :) |
I understand now.. Yes the watcher could be the problem. And I see several issues from others with hot module replacement as mentioned here #19 I am using webpack and I notice several times this issues using https://github.com/posthtml/posthtml-loader until I separate the posthtml config from webpack config by using https://github.com/posthtml/posthtml-load-config I am not sure if maizzle are using webpack, but perphas you can try using a separated posthtml config from webpack config? Maybe @cossssmin can check into. It's annoying but to me this seem to be something related with the watcher and not the plugin, considering that build works fine. Another workaround that I used for several times until I found above solution is to set props each time, even this is not ideal solution. Example in your case: <x-spacer height="16px"></x-spacer>
<div>Lorem ipsum dolor sit amet.</div>
<!-- Setting height to false will not use previous height value -->
<x-spacer height="false"></x-spacer> Let me know, in case I will try to do some more tests in your specific environment, if you can provide a simple repo how to reproduce it. |
Also please explain a bit more about this "dynamic" data. Do you mean something like this: <x-spacer height="{{ height }}"></x-spacer> |
Yes , when i send to component a custom value not a predefined. |
Ok, thanks for the help and sorry for bothering you. Have a nice day ! |
We're not using Webpack, for local dev we use Browsersync for both file watching (with chokidar) and for the local server. @quddoss this is what I use: <script props>
module.exports = {
height: props.height,
msoHeight: props.msoHeight,
}
</script>
<if condition="height">
<div
attributes
role="separator"
style="
{{ height ? `line-height: ${height}` : '' }};
{{ msoHeight ? `mso-line-height-alt: ${msoHeight}` : '' }};
"
>‍</div>
</if>
<else>
<div role="separator">‍</div>
</else> Using it with a 'dynamic' value in Maizzle (set in Front Matter in the template): ---
height: 20px
---
<x-main>
<fill:template>
<x-spacer height="{{ page.height }}"></x-spacer>
</fill:template>
</x-main> ... it compiles to |
Thanks @cossssmin , however I think that he has issue with following code: ---
height: 20px
---
<x-main>
<fill:template>
<x-spacer height="{{ page.height }}"></x-spacer>
<!-- Does this next render without height ? -->
<x-spacer></x-spacer>
</fill:template>
</x-main> |
Yes, it renders |
Ah great 👍 Thanks for testing. So maybe the issue with @quddoss is something else
|
First problem
Component:
Use it:
Result:
if I remove the height prop (attr) from x-spacer, the result is the same as above, and always takes the value specified before, although it should be:
not
if I rebuild the project again, then everything works fine until the prop height is declared
The second problem is that if I use it twice, the first one without the prop and the second one with it, the first one will inherit the value from the second one.
Use it:
Result:
The text was updated successfully, but these errors were encountered: