hgiesel / closet

The Web Framework for Flashcards
https://closetengine.com
GNU General Public License v3.0
65 stars 6 forks source link

Make delimiters configurable #28

Closed hgiesel closed 4 years ago

hgiesel commented 4 years ago

Specifically TAG_OPEN, TAG_CLOSE, ARG_SEP.

hgiesel commented 4 years ago

Supported since 3c105d856a04ac0e407dab8a454b2cce62a4ba88.

In order to set custom delimiters, you must call closet.setDelimiters('[[', '::', ']]'), where [[ is the open delimiter, :: the initial argument separator, and ]] the closing delimiter.

Incina76 commented 4 years ago

how would i go about this? I'm not sure what you mean by call.

hgiesel commented 4 years ago

Okay, so I revamped it, and thoroughly tested it this time.

Here's what you're gonna have to do:

  1. You go into the "Assets..." menu, select "Closet Setup"

  2. At an empty spot in the code, you paste this:

const delimiters =  {
    open: '<<',
    sep: '::',
    close: '>>'
}

As you can see, this contains the delimiters you want to use, &lt;&lt; corresponding to <<, etc.

  1. At the end of this setup, you change this:
return [[
    elements,
    memoryMap,
    filterManager,
]]

into:

return [[
    elements,
    memoryMap,
    filterManager,
    { delimiters },
]]

Now it should work. Tell me, if it works out for you.

Incina76 commented 4 years ago

I'll test it a soon as I can, but I'm at work for the next 7 hours.

Incina76 commented 4 years ago

Ok its working with <<>> fine. On my cards i ended up using {{ }} but changing the config to

const delimiters =  {
    open: '{{',
    sep: '::',
    close: '}}'
}

I get this error in preview.

Front template has a problem: Found '⁨{{', sep: '::', close: '}}⁩', but there is no field called '⁨ '⁩' More information

I can switch over my cards to use << >> though

hgiesel commented 4 years ago

You can circumvent this error by using backslashes:

const delimiters =  {
    open: '\{\{',
    sep: '::',
    close: '\}\}'
}
Incina76 commented 4 years ago

that worked thank you. you're awesome.