How to make uwosh.snippets work?

I didn't succeed to make uwosh.snippets work.

I guess the add-on has been properly installed: TinyMCE has a new button, the icon of which being {{}} (BTW, no tooltip: too bad). When I click on it, a popup asks me to add a snippet with: "Select content Search :/.snippets" but I don't what to do.

Following, I tried to "Navigate to the root of [my] site and go into the /.snippets folder" but no such folder: I even tried to reach it directly with http://localhost:8080/stage-latex/.snippets (http://localhost:8080/stage-latex being the root of site) but the page doesn't exist.

I'm a bit lost.

Maybe it'll be sufficient to create a folder and give it the ID ".snippets" (you might have to use the ZMI to rename it to have the ".")

Did you activate uwosh.snippets using the Add-ons control panel?

OK, got it after that (and indeed, it has been necessary to use the ZMI to rename it).

Yes (I guess this new {{}} button is a proof :slight_smile: But, "Activate "Snippets" (activating this product will create a folder called ".snippets" on the root level of your site" on is wrong here.

I could succeed to make it work: thanks!

Now, 2 questions:

  1. With the following HTML code of a snippet I created:
    le <span class="snippet-tag snippet-tag-document" contenteditable="false" data-type="snippet_tag" data-snippet-id="91703cee2a2b458dbe0c8103be2651d8">Snippet:[ID=91703cee2a2b458dbe0c8103be2651d8]</span>
    the word "le" and the following snippet are not on the same line: I consider this more as a bug than as a feature :wink:

  2. Is it possible to use a snippet in a Python script?

That is very old documentation and it describes the non-Plone 5 version of snippets. Best to stick with the docs (sorry, sorely lacking) in the GitHub repo or on pypi for that version. Or if you are able to contribute docs, I will be glad to merge any pull requests!

I wonder if that's a problem with using the span tag ... please file a bug in the GitHub repo[quote="dbitouze, post:4, topic:4399"]
Is it possible to use a snippet in a Python script?

I don't know. We didn't design it to do that. It should be possible, but I don't know how exactly. After all, it's just grabbing a piece of content that lives in the .snippets folder.

That might also need to be filed as an issue. I don't recall now if we'd decided not to create the folder on activation for the new P5 compatible version.


Feature requested.


1 Like

I made a small fix so that on activation the ".snippets" folder gets created correctly, and released version 2.0.1 to pypi

I found a way to get around the extra p tags that get automatically wrapped by TinyMCE around any text you put into the snippet (page) body:

I commented with some sample code that could work for you: