XF 2.2 "Missing closing `}`" -- When there isn't?

KensonPlays

Well-known member
This is really aggravating me. It is saying there's a missing closing } in extra.less, but it literally shows that it exists? This is really ticking me off and getting me all worked up; I don't like seeing "errors" in the error log.

LESS files (Extra and referenced):

The W3C validator says everything's valid (except for "Parse error {{ include('mh_banners.less') }}")

  • XF\CssRenderException: Error rendering template public:extra.less: ParseError: missing closing } in public:extra.less on line 4241, column 22 (on or near line 4241)
  • src/XF/CssRenderException.php:89

Stack Trace
Code:
 4238 |  }
 4239 |
 4240 | /* Quote BG Color */
*4241*|  .bbCodeBlock--quote { background-color: #8B0000; }
------------

#0 src/XF/CssRenderer.php(418): XF\CssRenderException::createFromLessException(Object(Less_Exception_Chunk), 'public:extra.le...', '// Note that th...')
#1 src/XF/CssRenderer.php(352): XF\CssRenderer->renderToCss('public:extra.le...', '// Note that th...')
#2 src/XF/CssRenderer.php(260): XF\CssRenderer->renderTemplate('public:extra.le...', NULL)
#3 src/XF/CssRenderer.php(118): XF\CssRenderer->renderTemplates(Array, Array, Array)
#4 src/XF/CssWriter.php(55): XF\CssRenderer->render(Array)
#5 css.php(30): XF\CssWriter->run(Array, 1, 1, 'a363adbf12c0d82...')
#6 {main}

-------------

Previous Less_Exception_Chunk: ParseError: missing closing `}` in anonymous-file-3148.less on line 4241, column 22
4239|
4240| /* Quote BG Color */
4241|  .bbCodeBlock--quote { background-color: #8B0000; } - src/vendor/oyejorge/less.php/lib/Less/Parser.php:677
#0 src/vendor/oyejorge/less.php/lib/Less/Parser.php(621): Less_Parser->GetRules(NULL)
#1 src/vendor/oyejorge/less.php/lib/Less/Parser.php(449): Less_Parser->_parse()
#2 src/XF/CssRenderer.php(414): Less_Parser->parse('// Note that th...')
#3 src/XF/CssRenderer.php(352): XF\CssRenderer->renderToCss('public:extra.le...', '// Note that th...')
#4 src/XF/CssRenderer.php(260): XF\CssRenderer->renderTemplate('public:extra.le...', NULL)
#5 src/XF/CssRenderer.php(118): XF\CssRenderer->renderTemplates(Array, Array, Array)
#6 src/XF/CssWriter.php(55): XF\CssRenderer->render(Array)
#7 css.php(30): XF\CssWriter->run(Array, 1, 1, 'a363adbf12c0d82...')
#8 {main}

Req State
Code:
array(4) {
  ["url"] => string(290) "/css.php?css=public%3Alightbox.less%2Cpublic%3Amessage.less%2Cpublic%3Anotices.less%2Cpublic%3Ashare_controls.less%2Cpublic%3AsvLazyImageLoader.less%2Cpublic%3Asv_bbcode_header.less%2Cpublic%3Axa_ubs.less%2Cpublic%3Aextra.less&s=1&l=1&d=1709705368&k=ee8c157f657424c16f9e835495757d032b6542a5"
  ["referrer"] => string(26) "https://mesozoichaven.com/"
  ["_GET"] => array(5) {
    ["css"] => string(183) "public:lightbox.less,public:message.less,public:notices.less,public:share_controls.less,public:svLazyImageLoader.less,public:sv_bbcode_header.less,public:xa_ubs.less,public:extra.less"
    ["s"] => string(1) "1"
    ["l"] => string(1) "1"
    ["d"] => string(10) "1709705368"
    ["k"] => string(40) "ee8c157f657424c16f9e835495757d032b6542a5"
  }
  ["_POST"] => array(0) {
  }
}
 
Last edited:
Solution
I'm unsure on why comments would be causing it. Isn't there a single line version of CSS comments? That is multi, I think?

Look at this screenshot. Because you never closed off the comment, it's assuming this bracket is also part of the commented CSS. You can see how it's orange (like a comment)

1710014150836.webp


This happens a few times on the CSS. I'm attaching a corrected version. It still has all the other comments which I think should get cleaned up but this won't throw errors.
Does anyone know what's causing this? I can't figure it out. (I'm no coder, like my sig says) It's filling my error log. Getting aggravating. 90 errors in log, with like 99% of them being this.
 
Can you post your extra.less here? If you want you can also shoot me a conversation with a copy of it and I can usually find this stuff pretty quick.
 
I linked to a github paste for it in the OP. That's the whole file, not sure why it thinks there's 4000 lines: https://gist.github.com/KensonPlayz/8063fba939b7d2aa6f5ef976e8bbbf5b
I completely missed those :).

I'm really curious, why are you commenting the css like this? It's making a mess of things and that's sort of the exact opposite thing which commenting is meant to do.

Do you really need to comment that background-size changes the background size? I don't get it?

You have quite a bit wrong in the template. You commented here on the background-position but never closed it off with */

Code:
/* Additonal adjustments for message-userBanner Only */
.userBanner.mhCreator.message-userBanner {
     background-position: 50% 0%; /*  adjusts image position (x% y%)
     text-indent: 0px;  /*  shifts text left or right */
     text-align: center;
}

Last, you have this in multiple places which isn't a valid comment, you like start the comment twice using /*

Code:
 /* padding-top: 0px;  /* remove the slashes and delete line above to remove image in mobile view */

Which is easier to read?
1710012597901.webp


1710012622014.webp
 
Just to be clear, you don't have a missing bracket as far as I can tell. Your comments are just not fully enclosed causing the CSS to break. Honestly ditch the way you're doing comments. You should not use comments to document what every single line does.
 
Just to be clear, you don't have a missing bracket as far as I can tell. Your comments are just not fully enclosed causing the CSS to break. Honestly ditch the way you're doing comments. You should not use comments to document what every single line does.
That was a template I just copy and pasted, so I didn't think much of it.
 
Gotcha, you'll need to go in and remove those lines I mentioned. They appear to be causing the problem. Let me know if you get stuck!
I'm unsure on why comments would be causing it. Isn't there a single line version of CSS comments? That is multi, I think?

Having those comments would help me significantly to understand what's happening, so if possible, i'd rather keep em.
 
Last edited:
I'm unsure on why comments would be causing it. Isn't there a single line version of CSS comments? That is multi, I think?

Look at this screenshot. Because you never closed off the comment, it's assuming this bracket is also part of the commented CSS. You can see how it's orange (like a comment)

1710014150836.webp


This happens a few times on the CSS. I'm attaching a corrected version. It still has all the other comments which I think should get cleaned up but this won't throw errors.
 

Attachments

Solution
Look at this screenshot. Because you never closed off the comment, it's assuming this bracket is also part of the commented CSS. You can see how it's orange (like a comment)

View attachment 299404


This happens a few times on the CSS. I'm attaching a corrected version. It still has all the other comments which I think should get cleaned up but this won't throw errors.
Much thanks. I'm more visual than textual, so having those comments will make it significantly easier to understand things.

(y)
 
Back
Top Bottom