+ Reply to Thread
Results 1 to 7 of 7

Thread: wiki.create broken

Hybrid View

  1. #1

    Default wiki.create broken

    Hi,

    trying to use the wiki.create command using the following three examples:

    {{ wiki.Create(label : "New Other Location", template : "LocationsPageTemplate", title : "New Other Location") }}
    {{ wiki.create(label : "New Other Location") }}
    {{ wiki.create() }}

    The first two break with a "line 1, column 19: ")" expected" error and the third works fine. Can anyone shed any light on this? I have even tried an example copied directly from the "How do I..." section on creating automatic pages with the same problem.

    DekiWiki 8.05.1

    Cheers,

    Andy.

  2. #2
    Join Date
    Jun 2008
    Posts
    140

    Default

    I'm a bit of a noob at this, but it looks like you are using the newer variable syntax. Try changing your ( ) for { } and see if that does the trick.

  3. #3

    Default

    Thanks for that - it worked.

    now I'm even more confused as to what the "standard" function syntax needs to be :-|

  4. #4
    Join Date
    Mar 2008
    Posts
    1,634

    Default

    I struggled with this a while before it all gelled. Here's a quick summary:

    The function parameter list is actually a map, which consists of a series of key/value pairs. A map is always enclosed in curly braces "{}". Other than that, you had the syntax correct. When using a map, you can specify the parameters in any order, and you can pick and choose which you include (though all required parameters must be specified in there somewhere.) So this would work fine:
    Code:
    {{ wiki.Create { label:"New Other Location", template:"LocationPageTemplate"} }}
    Dekiscript also gives you the shorthand option (probably more common) of specifying the paramteres as a list, and then it converts the list into a map for you. In this case, you enclose the list in regular parentheses "()", and just provide a list of the values you want passed in order as listed in the documentation. For the above example, it would look like this:
    Code:
    {{ wiki.Create("New Other Location", nil, "LocationPageTemplate") }}
    Note that because you're listing the values in order, you cannot skip optional arguments in the middle of the list, though you may leave off unwanted arguments at the end of the list. In this case, you didn't want to specify "path", so just put in "nil" (not in quotes) for that parameter, which is equivalent to not setting it. We can simply leave off the last two args ("button" and "title"), and they will likewise revert to defaults.

    Understanding maps is key to Dekiscript success. You can access a value in a map with the syntax map_name.key. The beloved "page" variable is a map (as are most of the wiki variables), so when you say "page.path", you're accessing a value in the map with the key "path". If you're in a template or a Dekiscript extension, you access the arguments with the "args" map, so if you have an argument named "date", you access it with "args.date". It's all quite consistent. Try printing out the "page" variable like this:
    Code:
    {{ page }}
    You'll see it's a big map, and the syntax matches that of the function calls you're making.

    Hope This Helps! [tm]

  5. #5
    Join Date
    Mar 2008
    Location
    Roseville, California USA
    Posts
    173

    Default

    NeilW,

    That was an clear, concise and thorough description and explanation of DekiScript syntax and maps. Could you post it in the developer.mindtouch wiki for posterity?

    Outstanding. You are a very good teacher.
    Aurora

    Questions relate to Deki server:
    OS: Ubuntu 10.04
    MindTouch v10 version 10.0.1 Non-VM

  6. #6
    Join Date
    Mar 2008
    Posts
    1,634

    Default

    Done.

    Hope those that would find it useful will find it.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts