<commit_before># PathJS #

PathJS is a lightweight, client-side routing library that allows you to create "single page" applications.

# Features #
* Lightweight
* Tested (tests available in the `./tests` directory)
* Supports the `onhashchange` method
* Supports paramaterized routes
* Supports Aspect Oriented Programming
* Compatible with all major browsers (Tested on Firefox 3.6, Firefox 4.0, Chrome 9, Opera 11, IE8)
* Allows you to define root routes, and rescue methods
* Independant of all third party libraries, but plays nice with all of them

# Using PathJS #

**Explanation**

PathJS allows you to bind methods to specific routes, providing you with the ability to dynamically change the content of your web page.  A route can be any string prepended with a hash, such as:

    #/my/first/route
    #!/hashbang/route
    #kittens

**Binding Routes**

PathJS provides the `Path` object.  This is the root of the library, and is your gateway into route-defining heaven.  You can define your routes like so:

    // Use an anonymous function
    Path.map("#/my/first/route").to(function(){
        alert("Hello, World!");
    });

    // Or define one and use it
    function hello_world(){
        alert("Hello, World!");
    }
    Path.map("#/kittens").to(hello_world);

**Aspect Oriented Programming**

In addition to defining methods that will be executed when a route is activated, you can define methods that will be called _before_ a route
is activated, and _after_ a route is left.  This can be done via the `enter` and `exit` methods, respectively.  They work exactly the same as
the `to` method:

    //Let's add an 'enter' method to one of our routes
	Path.map("#/my/first/route").enter(function(){
	    alert("Enter, minions!");
	});
	
	// You can also chain the methods together
	Path.map("#!/hashbang/route").enter(fade_in).to(function(){
	    alert("Method chaining is great!");
	}).exit(fade_out);

**Before Filters and Execution Halting**
In some cases, you may want to perform multiple actions before an action is taken, and depending on their results, cancel the action altogether.  For this reason, PathJS supports multiple 'enter' actions, which can be assigned individually or as an array:

    Path.map("#/my/first/route").enter(function(){
        alert("First one!");
    }).enter([
        function(){
            alert("Second!");
            return false;
        },
        function(){
            alert("And third!");
        }
    ]);
    
    Path.map("#/my/first/route").to(function(){
        alert("Action!")<commit_msg>Updated readme to explain before_filters<commit_after># PathJS #

PathJS is a lightweight, client-side routing library that allows you to create "single page" applications.

# Features #
* Lightweight
* Tested (tests available in the `./tests` directory)
* Supports the `onhashchange` method
* Supports paramaterized routes
* Supports Aspect Oriented Programming
* Compatible with all major browsers (Tested on Firefox 3.6, Firefox 4.0, Chrome 9, Opera 11, IE8)
* Allows you to define root routes, and rescue methods
* Independant of all third party libraries, but plays nice with all of them

# Using PathJS #

**Explanation**

PathJS allows you to bind methods to specific routes, providing you with the ability to dynamically change the content of your web page.  A route can be any string prepended with a hash, such as:

    #/my/first/route
    #!/hashbang/route
    #kittens

**Binding Routes**

PathJS provides the `Path` object.  This is the root of the library, and is your gateway into route-defining heaven.  You can define your routes like so:

    // Use an anonymous function
    Path.map("#/my/first/route").to(function(){
        alert("Hello, World!");
    });

    // Or define one and use it
    function hello_world(){
        alert("Hello, World!");
    }
    Path.map("#/kittens").to(hello_world);

**Aspect Oriented Programming**

In addition to defining methods that will be executed when a route is activated, you can define methods that will be called _before_ a route
is activated, and _after_ a route is left.  This can be done via the `enter` and `exit` methods, respectively.  They work exactly the same as
the `to` method:

    //Let's add an 'enter' method to one of our routes
	Path.map("#/my/first/route").enter(function(){
	    alert("Enter, minions!");
	});
	
	// You can also chain the methods together
	Path.map("#!/hashbang/route").enter(fade_in).to(function(){
	    alert("Method chaining is great!");
	}).exit(fade_out);

**Before Filters and Execution Halting**

In some cases, you may want to perform multiple actions before an action is taken, and depending on their results, cancel the action altogether.  For this reason, PathJS supports multiple 'enter' actions, which can be assigned individually or as an array:

    Path.map("#/my/first/route").enter(function(){
        alert("First one!");
    }).enter([
        function(){
            alert("Second!");
            return false;
        },
        function(){
            alert("And third!");
        }
    ]);
    
    Path.map("#/my/first/route").to(function(){
        alert("Action!")
{'fraction_non_alphanumeric': 0.10701822411787515, 'fraction_numerical': 0.0031019775106630476, 'mean_word_length': 3.401877133105802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6150583', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1393, 'n_words': 609}