Discourse-placeholder-theme-component

discourse-placeholder

This theme component will let you replace any =PATTERN= in a post with text input and selects.

:link: Repository Link

:link: Preview on Theme Creator

Usage

[wrap=placeholder key=NAME description="Your name"][/wrap]
[wrap=placeholder key=COUNTRY default=US defaults=FR,DE,US,CN,AU,CA][/wrap]

Your email: =NAME=-=COUNTRY=@example.com

This will result in:


We use it to create runbooks, howtos and reusable templates (it will work in code blocks). Please share your use cases!

27 Likes

Note: I will try to make it work in a theme component in the coming weeks.

10 Likes

I propose that there should be 4 things.

  1. Can sent detail to email.

or

  1. Can sent detail to inbox of post owner.

or

  1. Can print detail to PDF file for download.

and

  1. Can choose an image.

from%204

2 Likes

This is now available as a theme component, OP has been updated with info.

4 Likes

I’m interested in this, but I’m really not understanding what exactly it can do. Does it essentially just create variables that are local to a particular user’s form that they have filled out? Thus you can use the fields dynamically elsewhere on the same page prior to form submission?

Also, the current example displays the following that didn’t help me understand:

2 Likes

Preview should now work even if you are not logged in.

Try it, and maybe you will understand now, I made a more compelling sample.

6 Likes

Same here. @joffreyjaffeux, could you share some of your use cases in more detail? It sounds like it might be very useful, if only I understood it.

Thanks for this very useful feature.

To explain this, the key word for me is “runbook” which is a reference guide to the commands and procedures that I might need to use on my system.

This theme component allows me to create a generic runbook where each variable can be manually entered to customise commands for my system and any other system.

The post content can represent the content of a script or batch file. The manual inputs are the equivalent of runtime arguments but instead of entering them on the commandline, I enter them in a form.

Using the preview in the OP, the original post displays:

# move folder
cp -R =old_server_name= ./backup
mv =old_server_name= =new_server_name=

I’ve entered two variables which are my server names. The updated post now displays the commands for my system:

# move folder
cp -R OldServer ./backup
mv OldServer NewServer

AFAIK, the scope of the variables I enter is limited to that post.

Note that all variables have to be be manually entered as environment variables cannot be automatically filled in. Automatic entry of environment variables would be a great addition to this.

5 Likes

Yes runbooks is the main use case I created this component for.

# create a new plugin
rails g plugin =PLUGIN_NAME=
cd plugins/=PLUGIN_NAME=
6 Likes

EDIT. Sorry. some other theme component was causing a prolblem.

EDIT2: Or maybe I needed to reload the page? Now I can’t make it break again.

I just installed this theme component on a recent 2.4.0.beta6 and the descriptions are not displaying. Using the same text in OP I get:

And I can’t type in the boxes.

Am I doing something wrong?

How hard would it be to have this plugin, say, pull data from custom user fields?

1 Like

Thanks @joffreyjaffeux - this is really useful and we have just started using it in thepavilion.io for some templating and living documentation.

I’m interested in the ‘runbooks’ you mention - are you using GitHub - braintree/runbook: A framework for gradual system automation or are you using the term ‘runbook’ in its wider meaning?

6 Likes

Yes we call runbooks, any step by step process you would have to follow to achieve some operation which is not scripted (yet).

6 Likes