Closed mrmlnc closed 7 years ago
This is can be solved by:
while (conditionals.slice(-2).indexOf(nextTag.tag) > -1) {
// ...
obj.content = walk(opts, obj.content) // <------------------ ⚽️
ast.push(obj)
;[current, nextTag] = getNextTag(nodes, ++current)
}
But this is generate unnecessary whitespaces 😫
Expected:
<ul>\n\n\n <li>1</li>\n\n\n <li>2 % 2 === 0</li>\n\n\n
<li>3</li>\n\n</ul>
Actual:
<ul>\n \n \n <li>1</li>\n \n \n <li>2 % 2 === 0</li>\n \n
\n <li>3</li>\n \n</ul>
But this is behaviour was and before adding this line:
<ul>\n \n \n <li>{{ number }}</li>\n \n \n <li>2 % 2 === 0</li>\n \n \n <li>{{ number }}</li>\n \n</ul>
I haven't found time yet to take a look into it :), can you trim() within obj.content somewhere?
@michael-ciniawsky, no pressure 👍 I was just interested to solve this problem to run my Benchmark. I'll try to send PR but later.
@mrmlnc What are you benchmarking 👀 , is it compared to or in general :)? If you can fix it I rename and publish asap 😛
@michael-ciniawsky, I am looking for a replacement for Jade/Pug (veeeery slow for big pages: 2 loops, 2 conditions & 5 mixin references ~~ 1-2s/page).
I build simple stack with:
And...
I see, I have similiar intensions my 'dream' dev stack will/should look something like that
|- src
| |-components
| |-index.sml
| |-posthtml.config.js
|- index.sss
| |-components
| |-index.sss
| |-postcss.config.js
|- ...
|- package.json
postcss.config.js (done)
modules.exports = (ctx) => {
return {
parser: ctx.ext === '.sss' ? 'sugarss' : false,
plugins: {
'postcss-import': {},
'postcss-modules': {},
...,
'cssnano': ctx.env === 'production' ? {} : false
}
}
}
posthtml.config.js (needs update, in progress)
modules.exports = (ctx) => {
return {
parser: ctx.ext === '.sml' ? 'sugarml' : false,
plugins: {
'posthtml-include': {},
'posthtml-expressions': { locals: ctx.locals },
'posthtml-content': ctx.content,
'posthtml-extend': ctx.extend,
'posthtml-css-modules': {},
...(mixins || snippets)
...components // Plugin to write Single File Components with PostHTML instead of Vue.js
'htmlnano': ctx.env === 'production' ? {} : false
}
}
}
component.sml (prototype)
style(postcss [critical])
// Component CSS
template(id='[hash]', name='')
// Component HTML
script(babel [critical])
// Component JS
index.sml
doctype
head
style // Inline Single File Component Critical CSS here
link(href='index.sss') // With non-critical Single File Component JS + Deps (@import)
body
include(src='include.html')
component(src='component.html')
script // Inline Single File Component Critical JS here
script(src='index.js') // With non-critical Single File Component JS + Deps (import, require())
Besides that.. :), a mixin plugin is something important missing I tried a long time ago, but was not working as I wanted, interested in collab to find a good solution ?
@voischev What is the Issue with _.clonedeep
?
@michael-ciniawsky,
interested in collab to find a good solution ?
firstly I'll try to update posthtml-sugarml
, because right now it slows down the whole process. Then I think to rewrite benchmark for more realistic cases (include, extends and expressions) and compare performance. Right now Slm super fast but not have Mixins and plugins (not really important to me).
Now I not have a free time, but i put a note in Trello.
firstly I'll try to update posthtml-sugarml, because right now it slows down the whole process
You mean posthtml-expressions
instead of posthtml-sugarml
? Or maybe I'm not getting the context here :). If you meant posthtml-sugarml
can you file issue(s) over there, containing want you have in mind, I'm also currently shaping it a little, but suggestions on the how and contributions are welcome anytime and highly appreciated 😛 .
Mixins and plugins (not really important to me).
posthtml-mixins
let's draft/prototype/write that somehow 👍 .
@michael-ciniawsky, Yeap, I mean posthtml-sugarml
, because I think it's because of him posthtml gives such a bad result (I hope so).
And yeap, I can send PR tomorrow to posthtml-expressions
(100%) and posthtml-sugarml
(60%, because I have 57 assigned to me Issues on GitHub, pending fix 😄).
@mrmlnc a few minutes ago, there was an awesome PR out of the blue, which added scopes and a <scope>
tag to posthtml-expressions
, take your time of course no real urgency, but maybe, you can give it a portion of higher priority 👍 😛. Is there a fork of posthtml-sugarml
with your pushed changes so far, so I can sneak peek into it ? ;) It's because I refactored some code already, but mainly cosmetics and simplifcation.
@michael-ciniawsky,
Is there a fork of posthtml-sugarml with your pushed changes so far, so I can sneak peek into it
Nope, I just wanted to synchronize the current repository with Reshape repository.
As mentioned earlier, I patched this exact issue in reshape/expressions a while ago, happy to patch it here as well if you guys want, it would be quick and simple to do 😁
@jescalan, If you can do it, I would be happy ❤️.
Done, with a test to prevent regressions. Sorry this bug existed in the first place, it was definitely my oversight!
@jescalan, Thanks you ⭐️
@michael-ciniawsky cloneDeep
very slow :(
@voischev 👍 yep, never used lodash and friends myself, off topic here, but I have a personal aversion against this, because I can require('crap')
development model in general ;) although I'm NodeJS Dev
Detail
Moved from https://github.com/posthtml/sugarml/issues/7.
I'm use
sugar@0.1.0
(0.4.0
related to Reshape as I understand it) and I have following code:index.js
index.sml
After processing I get:
Output without
posthtml-exp
:Environment