urals-id-renderer

Id renderer by Urals tools
https://github.com/mnemesong/urals-id-renderer

To install, run:

haxelib install urals-id-renderer 0.0.1 

See using Haxelib in Haxelib documentation for more information.

README.md

urals-id-renderer

Description

Tools for render diff types of ids to htmlIdString. All packaged tools implements IdRendererInterface.

Requirements

Package tested for Haxe >= 4.0. The functionality or it missing of the package for lesser versions has not been tested.

Example of usage

...
import urals.IntIdRenderer;

var renderer = new IntIdRenderer("pref_");
assert(renderer.renderId(12) == "pref_12");
assert(renderer.parseId("pref_12") == 12);

General Interface

interface IdRendererInterface<Id>
{
    /**
        Translate some kind of id into html-id-string
        @throws Exception on not-biective-translatable string
    **/
    public function renderId(id: Id): String;

    /**
        Try to parse translated html-id-string back
        @throws Exception on parsing error
    **/
    public function parseId(id: String): Id;
}

Classes

  • IntIdRenderer(pref: String) - render and parse Int id with prefix
  • StringIdRenderer(pref: String) - render and parse String id with prefix

IdMatchHelper

//Helper for validate htmlIds and prefixes in them.
class IdMatchHelper 
{
    public static function isIdMatch(s: String): Bool {...}

    public static function assertIdMatch(s: String): Void {...}

    public static function isContainsPrefix(s: String, pref: String): Bool {...}

    public static function assertContainsPrefix(s: String, pref: String): Void {...}

    public static function removePrefix(s: String, pref: String): String {...}
}

Author

Anatoly Starodubtsev Tostar74@mail.ru

Contributors
Anatoly_Starodubtsev
Version
0.0.1
Published
3 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂