Skip to content
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

${} operator to expand attributes not working #354

Closed
thet opened this issue Apr 14, 2022 · 2 comments
Closed

${} operator to expand attributes not working #354

thet opened this issue Apr 14, 2022 · 2 comments

Comments

@thet
Copy link
Contributor

thet commented Apr 14, 2022

I tried this:

<label class="a b c ${wrapper_css_classes}" ${wrapper_attributes}>
...
</label>

But got the following error.

It would be really handy if I could just insert random attributes with the ${} variable expansion mechanism.

2022-04-14 13:20:27,243 ERROR   [Zope.SiteErrorLog:17][waitress-1] 1649935174.23567870.8504706171438358 http://localhost:8080/Plone/@@panel-users
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 371, in publish_module
  Module ZPublisher.WSGIPublisher, line 266, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module Products.PDBDebugMode.wsgi_runcall, line 60, in pdb_runcall
  Module zope.browserpage.simpleviewclass, line 41, in __call__
  Module Products.Five.browser.pagetemplatefile, line 126, in __call__
  Module Products.Five.browser.pagetemplatefile, line 58, in __call__
  Module zope.pagetemplate.pagetemplate, line 133, in pt_render
  Module Products.PageTemplates.engine, line 378, in __call__
  Module z3c.pt.pagetemplate, line 176, in render
  Module chameleon.zpt.template, line 302, in render
  Module chameleon.template, line 215, in render
  Module chameleon.utils, line 53, in raise_with_traceback
  Module chameleon.template, line 192, in render
  Module 4a85de36c3c609b6b7cdb6d7d6d3b32a, line 323, in render
  Module zope.tales.expressions, line 250, in __call__
  Module Products.PageTemplates.Expressions, line 225, in _eval
  Module Products.PageTemplates.Expressions, line 155, in render
  Module zope.browserpage.simpleviewclass, line 41, in __call__
  Module Products.Five.browser.pagetemplatefile, line 126, in __call__
  Module Products.Five.browser.pagetemplatefile, line 58, in __call__
  Module zope.pagetemplate.pagetemplate, line 129, in pt_render
   - Warning: Compilation failed
   - Warning: chameleon.exc.ParseError: Unexpected end tag.

 - String:     "</label>"
 - Filename:   /home/_thet/data/dev/syslab/REPOS/quaivesaas.buildout/src/ploneintranet/src/ploneintranet/userprofile/browser/templates/principal_in_sidebar.pt
 - Location:   (line 42: col 2)
 - Source:     </label>
               ^^^^^^^^
zope.pagetemplate.pagetemplate.PTRuntimeError: zope.pagetemplate.pagetemplate.PTRuntimeError: ['Compilation failed', 'chameleon.exc.ParseError: Unexpected end tag.\n\n - String:     "</label>"\n - Filename:   /home/_thet/data/dev/syslab/REPOS/quaivesaas.buildout/src/ploneintranet/src/ploneintranet/userprofile/browser/templates/principal_in_sidebar.pt\n - Location:   (line 42: col 2)\n - Source:     </label>\n               ^^^^^^^^']

 - Expression: "it/@@principal-in-sidebar"
 - Filename:   ... ploneintranet/microblog/browser/templates/panel_users.pt
 - Location:   (line 24: col 44)
 - Source:     ... l replace="structure it/@@principal-in-sidebar" />
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  template: <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x7f9855bbb6d0>
               options: {}
               args: ()
               nothing: None
               modules: <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter object at 0x7f986670d0d0>
               request: <WSGIRequest, URL=http://localhost:8080/Plone/@@panel-users>
               view: <Products.Five.browser.metaconfigure.SimpleViewClass from /home/_thet/data/dev/syslab/REPOS/quaivesaas.buildout/src/ploneintranet/src/ploneintranet/microblog/browser/templates/panel_users.pt object at 0x7f9855ad0c10>
               context: <PloneSite at /Plone>
               views: <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x7f9855ad0700>
               here: <PloneSite at /Plone>
               container: <PloneSite at /Plone>
               root: <Application at >
               traverse_subpath: []
               user: <PropertiedUser 'admin'>
               default: <DEFAULT>
               repeat: <Products.PageTemplates.engine.RepeatDictWrapper object at 0x7f9858f87840>
               loop: {'it': <Products.PageTemplates.engine.RepeatItem object at 0x7f9855ae7f10>}
               target_language: None
               translate: <function BaseTemplate.render.<locals>.translate at 0x7f9855a6d8b0>
               attrs: {}
               proto: <Products.Five.browser.metaconfigure.ProtoView object at 0x7f9855aa9cd0>
               it: {'description': '', 'getId': 'Plone', 'getURL': <function Users.result.<locals>.<lambda> at 0x7f9855a16b80>, 'has_thumbs': None, 'num_users': 123, 'portal_type': 'ploneintranet.userprofile.workgroup', 'Title': 'Workspace', 'title': 'Workspace', 'wrapper_css_classes': 'tiptap-item disable-patterns', 'wrapper_attributes': 'data-tiptap-value="Workspace"'}
[22] > /home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.pagetemplate-4.5.0-py3.9.egg/zope/pagetemplate/pagetemplate.py(129)pt_render()
-> raise PTRuntimeError(str(self._v_errors))
(Pdb++) c
@thet thet changed the title ${} operator to expend attributes not working ${} operator to expand attributes not working Apr 14, 2022
@malthe
Copy link
Owner

malthe commented Apr 14, 2022

But you can! Use tal:attributes="wrapper_attributes".

Something like that should work. It'll understand that it's a dict.

@thet
Copy link
Contributor Author

thet commented Apr 14, 2022

Oh, how nice. Thanks for the quick answer!
I'll close this issue then.

@thet thet closed this as completed Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants