Array of variables into snippets / shorthand

  • Advertisement ( why? )
     

    wavesource, 22nd Mar 2016 3:56 pm

    Hi Chami

    I have been had great fun using the double curly brackets to invoke variable entry fields for shorthand and snippets - here's a basic example - creating a snippet or shorthand containing the following:

    $database = "{{1. db}}";
    $username = "{{2. user}}";
    $password = "{{3. pass}}";
    $hostname = "localhost";

    I'm a shorthand nut, but now I've found this is working in snippets as well, I am in heaven.

    I was wondering if and how we would use an array in shorthand or snippets? ... A basic example, to create a list of fields just by looping over an single variable, eg.

    input =

    name1
    name2
    name3

    output =

    <input name="name1" id="name1" type="hidden" />
    <input name="name2" id="name2" type="hidden" />
    <input name="name3" id="name3" type="hidden" />

    Cheers and thanks for your work with Tools.

    David

    • HTML-Kit Support, 26th Mar 2016 3:31 pm

      Hey David, just a quick note to let you know that I'm working on this!
      Will get back by Monday with a ready to use solution.

    • HTML-Kit Support, 29th Mar 2016 5:11 pm

      On 3/22/2016 3:56 PM, wavesource wrote:

      Hi Chami

      I have been had great fun using the double curly brackets to invoke
      variable entry fields for shorthand and snippets - here's a basic
      example - creating a snippet or shorthand containing the following:

      $database = "{{1. db}}";
      $username = "{{2. user}}";
      $password = "{{3. pass}}";
      $hostname = "localhost";

      I'm a shorthand nut, but now I've found this is working in snippets
      as well, I am in heaven.

      I was wondering if and how we would use an array in shorthand or
      snippets? ... A basic example, to create a list of fields just by
      looping over an single variable, eg.

      input =

      name1
      name2
      name3

      output =

      <input name="name1" id="name1" type="hidden" />
      <input name="name2" id="name2" type="hidden" />
      <input name="name3" id="name3" type="hidden" />

      Cheers and thanks for your work with Tools.

      David

      Hi David,

      It's finally there!

      http://www.html-kit.com/tools/plugins/info/demojsgrid1/

      Install demoJSGrid1 as usual using "Tools > Install Plugin" menu option
      and then select "File > Insert > demoJSGrid1" to see it in action.

      You can then view its source code under "File > Insert > Edit and manage
      ... > demoJSGrid1" to create similar snippets. It's a bit more
      complicated because you're looping through a variable number of input
      fields and using them to output custom code, but it's fairly well commented.

      Hope this helps. Let me know if you have any questions. The new forum at
      https://support.htmlkit.com/forums/ is preferred but this is okay as well.

      Chami

      • wavesource, 30th Mar 2016 4:30 pm

        Yep, you nailed it :-) Using javascript - genius. I have only so much time to muck around with Tools, and this has opened my eyes.